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,33 @@ 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.
185
+
</details>
186
+
187
+
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.
188
+
189
+
See the [React Navigation deep linking docs](https://reactnavigation.org/docs/deep-linking?config=static#integrating-with-other-tools).
190
+
191
+
Learn more from our [docs](https://detour.swmansion.com/docs/SDK/sdk-usage).
164
192
165
193
### Controlling which links Detour processes
166
194
@@ -172,7 +200,10 @@ 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
219
220
+
### Clearing handled links
221
+
222
+
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.
223
+
224
+
## Analytics
225
+
226
+
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/) for the full event list and retention tracking setup.
241
+
187
242
## Examples
188
243
189
244
All example apps with Detour SDK integrated live in `examples/`:
@@ -231,10 +286,6 @@ pnpm android
231
286
232
287
> 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
288
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
289
## Types
239
290
240
291
The package exposes several types to help you with type-checking in your own codebase.
@@ -243,7 +294,10 @@ The package exposes several types to help you with type-checking in your own cod
243
294
244
295
This type is used to define the configuration object you pass to the DetourProvider.
245
296
246
-
```js
297
+
<details>
298
+
<summary>Config type</summary>
299
+
300
+
```ts
247
301
exporttypeConfig= {
248
302
/**
249
303
* Your application ID from the Detour dashboard.
@@ -257,7 +311,8 @@ export type Config = {
257
311
258
312
/**
259
313
* 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.
314
+
* Note: This feature is iOS-only. On Android, the SDK uses the install referrer for deterministic
315
+
* link matching instead; clipboard is never accessed regardless of this setting.
261
316
* When enabled on iOS, it may display a permission alert to the user.
262
317
* Defaults to true if not provided.
263
318
*/
@@ -279,11 +334,16 @@ export type Config = {
279
334
};
280
335
```
281
336
337
+
</details>
338
+
282
339
### DetourContextType
283
340
284
341
This type represents the object returned by the `useDetourContext` hook, containing the resolved link and its processing status.
285
342
286
-
```js
343
+
<details>
344
+
<summary>DetourContextType type</summary>
345
+
346
+
```ts
287
347
exporttypeDetourContextType= {
288
348
/**
289
349
* Boolean indicating if the initial link (deferred, Universal/App Link, or scheme) has been processed.
@@ -303,11 +363,16 @@ export type DetourContextType = {
303
363
};
304
364
```
305
365
366
+
</details>
367
+
306
368
### DetourLink
307
369
308
370
The resolved link object, or null if no link was found.
309
371
310
-
```js
372
+
<details>
373
+
<summary>DetourLink type</summary>
374
+
375
+
```ts
311
376
exporttypeDetourLink= {
312
377
/** The original link URL as received by the SDK. */
0 commit comments