# Installation

Detour provides a React Native SDK (`@swmansion/react-native-detour`) compatible with Expo and bare React Native projects.

Before installation, make sure your app is created in the Detour Dashboard and you have:

- `appID` from **API configuration**
- publishable `apiKey` from **API configuration**
- platform integration snippets from **App configuration**

## Install package

```bash
    npm install @swmansion/react-native-detour
    ```
  ```bash
    yarn add @swmansion/react-native-detour
    ```
  ```bash
    pnpm add @swmansion/react-native-detour
    ```
  ```bash
    bun add @swmansion/react-native-detour
    ```
  ## Install peer dependencies

```bash
    npm install expo-localization react-native-device-info expo-clipboard @react-native-async-storage/async-storage expo-application
    ```
  ```bash
    yarn add expo-localization react-native-device-info expo-clipboard @react-native-async-storage/async-storage expo-application
    ```
  ```bash
    pnpm add expo-localization react-native-device-info expo-clipboard @react-native-async-storage/async-storage expo-application
    ```
  ```bash
    bun add expo-localization react-native-device-info expo-clipboard @react-native-async-storage/async-storage expo-application
    ```
  :::note[Device info provider]
`react-native-device-info` is a required peer dependency. Unlike storage, the device info source is not configurable. The SDK imports the library directly to read the device model, manufacturer, OS version, and user agent for the deferred-link fingerprint. There is no adapter to plug in.
:::

:::note[Custom storage]
`@react-native-async-storage/async-storage` is optional if you provide a custom storage adapter in config. See [Custom Storage](https://detour.swmansion.com/docs/sdk/react-native/custom-storage).
:::

:::note[Expo managed workflow]
After installing `react-native-device-info` in Expo managed workflow, create a custom development build:
https://docs.expo.dev/develop/development-builds/introduction/
:::

## Credentials in app config

```ts
import { type Config } from '@swmansion/react-native-detour';

export const detourConfig: Config = {
  apiKey: process.env.EXPO_PUBLIC_DETOUR_API_KEY!,
  appID: process.env.EXPO_PUBLIC_DETOUR_APP_ID!,
  shouldUseClipboard: true,
};
```

Keep `apiKey` and `appID` in environment variables or another secure configuration layer.

## Next steps

1. Implement the provider and link handling in [Usage](https://detour.swmansion.com/docs/sdk/react-native/sdk-usage).
2. Pick a runnable app pattern in [Examples](https://detour.swmansion.com/docs/sdk/react-native/examples).
3. If upgrading existing code, follow [Migration to v1](https://detour.swmansion.com/docs/sdk/react-native/1.0.1/migration-1-0-1).