You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You need a Detour account to generate app credentials and configure your links.
14
-
Sign up here: [https://godetour.dev/auth/signup](https://godetour.dev/auth/signup)
9
+
React Native Detour is an SDK for handling deferred deep links in React Native. A deferred link works like a regular deep link, but survives the App Store or Play Store install — a user who clicks a link before having the app installed is redirected to the right screen on first launch. Detour also handles Universal/App links and custom scheme links in a single unified API.
You need a Detour account to generate app credentials and configure your links.
19
+
Sign up here: [https://godetour.dev/auth/signup](https://godetour.dev/auth/signup)
28
20
29
21
## Installation
30
22
@@ -48,19 +40,34 @@ npm install expo-device
48
40
npm install react-native-device-info
49
41
```
50
42
51
-
> You can override the default persistent storage (@react-native-async-storage/async-storage) by providing an alternative storage implementation. Pass your custom storage object via the configuration settings.
43
+
> You can override the default persistent storage (`@react-native-async-storage/async-storage`) by providing an alternative storage implementation via the `storage` config option.
44
+
>
45
+
> For device info, install either `expo-device` or `react-native-device-info` — at least one is required. If your project already uses one of them, no extra installation is needed.
52
46
53
47
## Usage
54
48
55
-
### Initialize the provider
49
+
Mount `DetourProvider` at the root of your app and configure it with your credentials. How you consume the resolved link depends on your navigation library.
50
+
51
+
> The SDK is a no-op on Expo Web — `DetourProvider` mounts but link processing is skipped and `isLinkProcessed` resolves immediately to `true`.
52
+
53
+
### Expo Router
54
+
55
+
Wrap your root layout with `DetourProvider`, then use the `useDetourContext` hook to read the resolved link and drive navigation. If your app uses Expo Router's `+native-intent.tsx` to handle Universal/App links, import `createDetourNativeIntentHandler` from `@swmansion/react-native-detour/expo-router` and set `linkProcessingMode: 'deferred-only'` — Detour will only handle deferred links and let the native intent handler take care of the rest. See [`examples/expo-router-native-intent`](./examples/expo-router-native-intent) for a working setup.
Pass Detour's linking adapter to `NavigationContainer`. React Navigation will handle routing automatically — `useDetourContext` is not needed for basic usage. The splash screen is hidden via `onReady`, which fires after `getInitialURL` resolves.
A deep link that arrives while the user is signed-out is parsed, found unreachable (the target
161
-
screen isn't currently rendered), and remembered. When the rendered screen set changes — after
162
-
sign-in, then again after onboarding — React Navigation retries and lands the user on the target.
163
-
See `examples/react-navigation-advanced` for a working setup.
197
+
</details>
198
+
199
+
A deep link that arrives while the user is signed-out is parsed, found unreachable, and remembered. When the rendered screen set changes after sign-in or onboarding, React Navigation retries and lands the user on the target. See [`examples/react-navigation-advanced`](./examples/react-navigation-advanced) for a working setup.
200
+
201
+
See the [React Navigation deep linking docs](https://reactnavigation.org/docs/deep-linking?config=static#integrating-with-other-tools).
202
+
203
+
Learn more from our [docs](https://detour.swmansion.com/docs/sdk/react-native/sdk-usage).
164
204
165
205
### Controlling which links Detour processes
166
206
@@ -172,18 +212,45 @@ Use `linkProcessingMode` to control which link sources the SDK listens to:
Use `'deferred-only'` when Expo Router's `+native-intent.tsx` handler is already resolving runtime Universal/App links — this prevents double-processing.
186
231
232
+
### Clearing handled links
233
+
234
+
If your app redirects based on `link` (especially in entry screens), call `clearLink()` after handling the route. This prevents repeated redirects when the user returns to the same screen.
235
+
236
+
## Analytics
237
+
238
+
The SDK includes a built-in analytics module. `DetourProvider` automatically tracks app opens for retention. You can also log custom events using the predefined `DetourEventNames` enum:
See the [analytics docs](https://detour.swmansion.com/docs/Fundamentals/analytics-detour) for the full event list and retention tracking setup.
253
+
187
254
## Examples
188
255
189
256
All example apps with Detour SDK integrated live in `examples/`:
@@ -231,10 +298,6 @@ pnpm android
231
298
232
299
> Running `pnpm ios` / `pnpm android` produces a development build. This is recommended over Expo Go for testing deep linking flows on a real device.
233
300
234
-
## Clearing handled links
235
-
236
-
If your app redirects based on `link` (especially in entry screens), call `clearLink()` after handling the route. This prevents repeated redirects when the user returns to the same screen.
237
-
238
301
## Types
239
302
240
303
The package exposes several types to help you with type-checking in your own codebase.
@@ -243,7 +306,10 @@ The package exposes several types to help you with type-checking in your own cod
243
306
244
307
This type is used to define the configuration object you pass to the DetourProvider.
245
308
246
-
```js
309
+
<details>
310
+
<summary>Config type</summary>
311
+
312
+
```ts
247
313
exporttypeConfig= {
248
314
/**
249
315
* Your application ID from the Detour dashboard.
@@ -257,7 +323,8 @@ export type Config = {
257
323
258
324
/**
259
325
* Optional: A flag to determine if the provider should check the clipboard for a deferred link.
260
-
* Note: This feature is iOS-only. On Android, clipboard is never accessed regardless of this setting.
326
+
* Note: This feature is iOS-only. On Android, the SDK uses the install referrer for deterministic
327
+
* link matching instead; clipboard is never accessed regardless of this setting.
261
328
* When enabled on iOS, it may display a permission alert to the user.
262
329
* Defaults to true if not provided.
263
330
*/
@@ -270,7 +337,7 @@ export type Config = {
270
337
* - 'deferred-only': only deferred links (use when native-intent already handles runtime links)
0 commit comments