@@ -58,15 +58,16 @@ Wrap your root layout with `DetourProvider`, then use the `useDetourContext` hoo
5858<summary >Expo Router example</summary >
5959
6060``` tsx
61- import { DetourProvider , useDetourContext , type Config } from ' @swmansion/react-native-detour' ;
6261import { Stack , usePathname , useRouter } from " expo-router" ;
6362import * as SplashScreen from " expo-splash-screen" ;
6463
64+ import { type Config , DetourProvider , useDetourContext } from " @swmansion/react-native-detour" ;
65+
6566SplashScreen .preventAutoHideAsync ();
6667
6768const config: Config = {
68- apiKey: ' <REPLACE_WITH_YOUR_API_KEY>' ,
69- appID: ' <REPLACE_WITH_APP_ID_FROM_PLATFORM>' ,
69+ apiKey: " <REPLACE_WITH_YOUR_API_KEY>" ,
70+ appID: " <REPLACE_WITH_APP_ID_FROM_PLATFORM>" ,
7071};
7172
7273export default function RootLayout() {
@@ -117,15 +118,22 @@ Pass Detour's linking adapter to `NavigationContainer`. React Navigation will ha
117118<summary >React Navigation example</summary >
118119
119120``` tsx
120- import { DetourProvider , DETOUR_LINKING_PREFIX , Detour , type Config } from ' @swmansion/react-native-detour' ;
121- import { NavigationContainer } from ' @react-navigation/native' ;
122- import * as SplashScreen from ' expo-splash-screen' ;
121+ import * as SplashScreen from " expo-splash-screen" ;
122+
123+ import { NavigationContainer } from " @react-navigation/native" ;
124+
125+ import {
126+ type Config ,
127+ DETOUR_LINKING_PREFIX ,
128+ Detour ,
129+ DetourProvider ,
130+ } from " @swmansion/react-native-detour" ;
123131
124132SplashScreen .preventAutoHideAsync ();
125133
126134const config: Config = {
127- apiKey: ' <REPLACE_WITH_YOUR_API_KEY>' ,
128- appID: ' <REPLACE_WITH_APP_ID_FROM_PLATFORM>' ,
135+ apiKey: " <REPLACE_WITH_YOUR_API_KEY>" ,
136+ appID: " <REPLACE_WITH_APP_ID_FROM_PLATFORM>" ,
129137};
130138
131139const linking = {
@@ -134,7 +142,7 @@ const linking = {
134142 return await Detour .getInitialURL ();
135143 },
136144 subscribe(listener ) {
137- const subscription = Detour .addEventListener (' url' , ({ url }) => {
145+ const subscription = Detour .addEventListener (" url" , ({ url }) => {
138146 listener (url );
139147 });
140148 return () => subscription .remove ();
@@ -171,14 +179,18 @@ behavior on the navigator:
171179
172180``` tsx
173181<Stack.Navigator UNSTABLE_routeNamesChangeBehavior = " lastUnhandled" >
174- { isSignedIn
175- ? isOnboardingCompleted
176- ? <>
177- <Stack.Screen name = " Tabs" component = { TabNavigator } />
178- <Stack.Screen name = " Details" component = { Details } />
179- </>
180- : <Stack.Screen name = " Onboarding" component = { Onboarding } />
181- : <Stack.Screen name = " SignIn" component = { SignIn } />}
182+ { isSignedIn ? (
183+ isOnboardingCompleted ? (
184+ <>
185+ <Stack.Screen name = " Tabs" component = { TabNavigator } />
186+ <Stack.Screen name = " Details" component = { Details } />
187+ </>
188+ ) : (
189+ <Stack.Screen name = " Onboarding" component = { Onboarding } />
190+ )
191+ ) : (
192+ <Stack.Screen name = " SignIn" component = { SignIn } />
193+ )}
182194</Stack.Navigator >
183195```
184196
@@ -188,7 +200,7 @@ A deep link that arrives while the user is signed-out is parsed, found unreachab
188200
189201See the [ React Navigation deep linking docs] ( https://reactnavigation.org/docs/deep-linking?config=static#integrating-with-other-tools ) .
190202
191- Learn more from our [ docs] ( https://detour.swmansion.com/docs/SDK /sdk-usage ) .
203+ Learn more from our [ docs] ( https://detour.swmansion.com/docs/sdk/react-native /sdk-usage ) .
192204
193205### Controlling which links Detour processes
194206
@@ -205,11 +217,11 @@ Use `linkProcessingMode` to control which link sources the SDK listens to:
205217
206218``` ts
207219const config: Config = {
208- apiKey: ' <REPLACE_WITH_YOUR_API_KEY>' ,
209- appID: ' <REPLACE_WITH_APP_ID_FROM_PLATFORM>' ,
220+ apiKey: " <REPLACE_WITH_YOUR_API_KEY>" ,
221+ appID: " <REPLACE_WITH_APP_ID_FROM_PLATFORM>" ,
210222 // Process Universal/App links and deferred links, but let your own
211223 // navigation layer handle custom scheme links (e.g. myapp://...).
212- linkProcessingMode: ' web-only' ,
224+ linkProcessingMode: " web-only" ,
213225};
214226```
215227
@@ -229,15 +241,15 @@ The SDK includes a built-in analytics module. `DetourProvider` automatically tra
229241<summary >Analytics example</summary >
230242
231243``` ts
232- import { DetourAnalytics , DetourEventNames } from ' @swmansion/react-native-detour' ;
244+ import { DetourAnalytics , DetourEventNames } from " @swmansion/react-native-detour" ;
233245
234246DetourAnalytics .logEvent (DetourEventNames .Purchase );
235- DetourAnalytics .logRetention (' week_1' );
247+ DetourAnalytics .logRetention (" week_1" );
236248```
237249
238250</details >
239251
240- See the [ analytics docs] ( https://detour.swmansion.com/docs/ ) for the full event list and retention tracking setup.
252+ See the [ analytics docs] ( https://detour.swmansion.com/docs/Fundamentals/analytics-detour ) for the full event list and retention tracking setup.
241253
242254## Examples
243255
@@ -325,7 +337,7 @@ export type Config = {
325337 * - 'deferred-only': only deferred links (use when native-intent already handles runtime links)
326338 * Defaults to 'all'.
327339 */
328- linkProcessingMode? : ' all' | ' web-only' | ' deferred-only' ;
340+ linkProcessingMode? : " all" | " web-only" | " deferred-only" ;
329341
330342 /**
331343 * Optional: A custom storage adapter. Defaults to AsyncStorage if not provided.
0 commit comments