# Migration to v1

This guide helps migrate from older RN SDK integration patterns to `@swmansion/react-native-detour@1.0.1`.

## Migration checklist

| Area | Before | In `1.0.1` |
| --- | --- | --- |
| Config key | `API_KEY` | `apiKey` |
| Context shape | `linkRoute`, `linkUrl`, `linkType` exposed directly | `link` object (`route`, `pathname`, `params`, `url`, `type`) |
| Navigation mapping | Parse route string manually | Prefer `link.pathname` and `link.params` |
| Link-source control | No explicit mode | `linkProcessingMode: 'all' \| 'web-only' \| 'deferred-only'` |
| Expo Router native intent | Custom handler only | Optional `createDetourNativeIntentHandler` from `@swmansion/react-native-detour/expo-router` |
| Analytics export const redirectSystemPath = createDetourNativeIntentHandler({
  fallbackPath: '',
  config: {
    apiKey: process.env.EXPO_PUBLIC_DETOUR_API_KEY!,
    appID: process.env.EXPO_PUBLIC_DETOUR_APP_ID!,
    timeoutMs: 1200,
  },
});

// app/_layout.tsx
const config = {
  apiKey: process.env.EXPO_PUBLIC_DETOUR_API_KEY!,
  appID: process.env.EXPO_PUBLIC_DETOUR_APP_ID!,
  linkProcessingMode: 'deferred-only',
};
```

If you need custom path shaping (for example dropping app-hash segment), use the handler `mapToRoute` callback.

### Related resources

- [Usage: Expo Router native intent helper](https://detour.swmansion.com/docs/sdk/react-native/sdk-usage#expo-router-integration)
- [Examples](https://detour.swmansion.com/docs/sdk/react-native/examples) (`expo-router-native-intent`, `expo-router-advanced`)
- Expo Router docs: [Customizing links with +native-intent](https://docs.expo.dev/router/advanced/native-intent/)

## Validate after migration

1. Trigger deferred link on fresh install and confirm `link?.type === 'deferred'`.
2. Trigger runtime Universal/App Link and confirm `link?.type === 'verified'`.
3. Trigger custom scheme link and confirm expected behavior for selected `linkProcessingMode`.
4. Confirm only one `DetourProvider` is mounted.