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:
appIDfrom API configuration- publishable
apiKeyfrom API configuration - platform integration snippets from App configuration
Install package
Section titled “Install package”npm install @swmansion/react-native-detouryarn add @swmansion/react-native-detourpnpm add @swmansion/react-native-detourbun add @swmansion/react-native-detourInstall peer dependencies (Expo projects)
Section titled “Install peer dependencies (Expo projects)”For Expo projects (including prebuild), install peer dependencies with Expo CLI so versions are matched to your Expo SDK:
npx expo install expo-application expo-clipboard expo-constants expo-device expo-localization @react-native-async-storage/async-storageBare React Native projects
Section titled “Bare React Native projects”If you are not using Expo CLI, install peer dependencies with your package manager and pin versions compatible with your React Native/Expo Modules setup.
npm install expo-application expo-clipboard expo-constants expo-device expo-localization @react-native-async-storage/async-storageyarn add expo-application expo-clipboard expo-constants expo-device expo-localization @react-native-async-storage/async-storagepnpm add expo-application expo-clipboard expo-constants expo-device expo-localization @react-native-async-storage/async-storagebun add expo-application expo-clipboard expo-constants expo-device expo-localization @react-native-async-storage/async-storageExpo Modules setup (React Native CLI)
Section titled “Expo Modules setup (React Native CLI)”The peer dependencies above (expo-application, expo-clipboard, expo-constants, expo-localization) are Expo Modules, and they ship native code that has to be autolinked into your android/ and ios/ projects. In an Expo project this happens automatically. In a bare React Native CLI project you add Expo Modules once:
npx install-expo-modules@latestThis sets up Expo Modules autolinking (and on iOS raises the deployment target to the Expo Modules minimum).
install-expo-modules also switches the native JS bundling step to Expo CLI (export:embed), which requires metro.config.js to extend expo/metro-config (a superset of @react-native/metro-config, safe in bare projects). The tool usually migrates this for you. Verify it, especially if you had a customized metro.config.js:
const { getDefaultConfig } = require("expo/metro-config");const { mergeConfig } = require("@react-native/metro-config");
module.exports = mergeConfig(getDefaultConfig(__dirname), {});Then align the Expo package versions to your setup:
npx expo install --fixCredentials in app config
Section titled “Credentials in app config”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
Section titled “Next steps”- Implement the provider and link handling in Usage.
- Pick a runnable app pattern in Examples.
- If upgrading existing code, follow Migration to v2 and start from From 0.x or From 1.0.1.