<!-- KeepSnappy docs for keepsnappy CLI 0.1.0-alpha.35 -->

# Install by hand

> Which versions of the SDK, the Appium driver and the keepsnappy command go together, how to install them by hand, and the two config changes the SDK needs.

This page is for whoever sets up the SDK by hand, when `keepsnappy init` leaves a step to you. It gives the versions that work together, the install commands and the two config changes. [The measuring build](https://keepsnappy.com/docs/sdk.md) says what the SDK does.

## Versions that work together

The SDK, the Appium driver and the `keepsnappy` command are released separately. Each version of the `keepsnappy` command was tested with the SDK and driver versions on its row. The commands on this page install the latest releases, which are the newest row. If you pin versions, take them all from one row.

`keepsnappy init` adds `@keepsnappy/react-native` and `@keepsnappy/agent`. When the SDK in your app is outside the row, `keepsnappy doctor --group app` warns, names the tested versions and prints the command that installs the right one.

A BrowserStack [journey module](https://keepsnappy.com/docs/test-tools/appium.md#other-setups) is a JavaScript file that imports the Appium driver. Install the driver separately:

```sh
npm install --save-dev --save-exact @keepsnappy/appium-driver
```

<!-- compatible-sets:start -->
| keepsnappy | @keepsnappy/react-native | @keepsnappy/appium-driver |
|---|---|---|
| 0.1.0-alpha.27 | 0.1.0-alpha.27 | 0.1.0-alpha.27 |
| 0.1.0-alpha.28 | 0.1.0-alpha.27 | 0.1.0-alpha.27 to 0.1.0-alpha.28 |
| 0.1.0-alpha.29 | 0.1.0-alpha.27 | 0.1.0-alpha.27 to 0.1.0-alpha.28 |
| 0.1.0-alpha.30 | 0.1.0-alpha.27 | 0.1.0-alpha.27 to 0.1.0-alpha.28 |
| 0.1.0-alpha.31 | 0.1.0-alpha.27 | 0.1.0-alpha.27 to 0.1.0-alpha.28 |
| 0.1.0-alpha.32 | 0.1.0-alpha.27 | 0.1.0-alpha.27 to 0.1.0-alpha.28 |
| 0.1.0-alpha.33 | 0.1.0-alpha.27 | 0.1.0-alpha.27 to 0.1.0-alpha.28 |
| 0.1.0-alpha.34 | 0.1.0-alpha.27 | 0.1.0-alpha.27 to 0.1.0-alpha.28 |
| 0.1.0-alpha.35 | 0.1.0-alpha.27 | 0.1.0-alpha.27 to 0.1.0-alpha.28 |
<!-- compatible-sets:end -->

Each new release adds its row.

The `keepsnappy` command is the package `@keepsnappy/agent`. There is no `@keepsnappy/cli`.

## Install and build by hand

<span id="the-command-line-tool"></span>You need:

- An Expo app, or a bare React Native app with the `expo` package and Expo modules ([Bare React Native](https://keepsnappy.com/docs/bare-react-native.md)).
- Node.js 22.12 or newer, for the `keepsnappy` command.
- For iOS, Xcode and an iOS simulator on a Mac. In CI, that is a macOS CI machine, such as GitHub Actions `macos-15`.

Add the SDK, and the `keepsnappy` command as a dev dependency. `--save-exact` records the exact version npm installs, so every machine gets the same one:

```sh
npm install --save-exact @keepsnappy/react-native
npm install --save-dev --save-exact @keepsnappy/agent
```

Make the [two config changes](#two-config-changes), then create `keepsnappy.yml` in your app's repository root. For an iOS simulator with Maestro, start with:

```yaml
app:
  bundle_id: com.example.app
flows:
  runner: maestro
  paths:
    - .maestro/
```

Use your app’s bundle ID and the path to its existing Maestro flows. For another runner, use the [test command example](https://keepsnappy.com/docs/settings.md#keepsnappyyml). For Android, use the application ID, link scheme and platform from the [Android emulator example](https://keepsnappy.com/docs/android.md#your-tests-on-the-emulator).

To check the app's setup without CI, run:

```sh
npx --no-install keepsnappy doctor --group app --local
```

Every line should start with `ok`. Under a line that doesn't, doctor says what to fix.

Without the dev dependency, `npx @keepsnappy/agent doctor --group app --local` runs the same check.

Then build your app with the build switch on ([Make a Release build](https://keepsnappy.com/docs/sdk.md#make-a-release-build)).

## Two config changes

### Wrap your Metro config

`withKeepSnappy` must be the outermost wrapper.

```js
// metro.config.js
const { getDefaultConfig } = require('expo/metro-config');
const { withKeepSnappy } = require('@keepsnappy/react-native/metro');

module.exports = withKeepSnappy(getDefaultConfig(__dirname));
```

If your Metro config is an ES module, `require` and `module.exports` don't work in it. That is a `metro.config.mjs` or `metro.config.mts`, a config with `import` or `export` lines, or a `metro.config.js` in a package whose `type` is `module`. Import the wrapper by its file name, `@keepsnappy/react-native/metro.js`:

```js
// metro.config.mjs or metro.config.ts
import { getDefaultConfig } from 'expo/metro-config.js';
import { withKeepSnappy } from '@keepsnappy/react-native/metro.js';

const config = getDefaultConfig(import.meta.dirname);

export default withKeepSnappy(config);
```

Init leaves an ES module config to you and prints the two lines to add. `keepsnappy doctor` checks the import. In a `metro.config.ts`, doctor may warn that the SDK ships no types for that path (TS7016). The build still works.

The SDK names each component by the file it is defined in, for the components of your own project. In a monorepo, it names a component from another workspace package only when you list that package:

```js
module.exports = withKeepSnappy(getDefaultConfig(__dirname), { clientPackages: ['@my-app/ui'] });
```

### Add the config plugin

Add it to `app.json`, or to the `plugins` list of `app.config.js`:

```json
{
  "expo": {
    "plugins": [
      ["@keepsnappy/react-native", { "measureFromLaunch": true, "renderTimes": true }]
    ]
  }
}
```

[Plugin options](https://keepsnappy.com/docs/sdk.md#plugin-options) says what each option does.

## Next

Build your app with the build switch on: [Make a Release build](https://keepsnappy.com/docs/sdk.md#make-a-release-build).

All KeepSnappy docs for agents: https://keepsnappy.com/llms.txt
