@@ -4,23 +4,98 @@ sdk for handling deferred links
44
55## Installation
66
7-
87``` sh
98npm install detour-react-native
109```
1110
11+ #### You need to install additional dependencies
12+
13+ ``` sh
14+ npm install expo-localization react-native-device-info expo-clipboard @react-native-async-storage/async-storage
15+ ```
1216
1317## Usage
1418
19+ #### Initialize provider in root of your app
1520
1621``` js
17- import { multiply } from ' detour-react-native' ;
22+ import { DetourProvider , type Config } from ' detour-react-native' ;
23+
24+ export default function App () {
25+ const config: Config = {
26+ API_KEY : ' ssss-ssss-ssss' ,
27+ appID: ' app-id-from-dashboard' ,
28+ shouldUseClipboard: true ,
29+ };
30+
31+ return (
32+ < DetourProvider config= {config}>
33+ // rest of app content
34+ < / DetourProvider> )
35+ }
36+ ```
37+
38+ #### Use values from context
39+
40+ ``` js
41+ import { useDetourContext } from ' detour-react-native' ;
42+
43+ // inside component
44+ const { deferredLink , deferredLinkProcessed , route } = useDetourContext ();
45+ ```
46+
47+ ## Types
48+
49+ The package exposes several types to help you with type-checking in your own codebase.
1850
19- // ...
51+ ** Config **
2052
21- const result = await multiply (3 , 7 );
53+ This type is used to define the configuration object you pass to the DetourProvider.
54+
55+ ``` js
56+ export type Config = {
57+ /**
58+ * Your application ID from the Detour dashboard.
59+ */
60+ appID : string ;
61+
62+ /**
63+ * Your API key from the Detour dashboard.
64+ */
65+ API_KEY : string ;
66+
67+ /**
68+ * Optional: A flag to determine if the provider should check the clipboard for a deferred link.
69+ * When true, it displays permission alert to user.
70+ * Defaults to true if not provided.
71+ */
72+ shouldUseClipboard ?: boolean ;
73+ };
2274```
2375
76+ ** DeferredLinkContext**
77+
78+ This type represents the object returned by the useDetourContext hook, containing the deferred link and its processing status.
79+
80+ ``` js
81+ export type DeferredLinkContext = {
82+ /**
83+ * Boolean indicating if the deferred link has been processed.
84+ * This is useful for conditionally rendering UI components.
85+ */
86+ deferredLinkProcessed : boolean ;
87+
88+ /**
89+ * The deferred link value. This can be a string or a URL object, or null if no link was found.
90+ */
91+ deferredLink : string | URL | null ;
92+
93+ /**
94+ * The detected route based on the deferred link, or null if no route was detected.
95+ */
96+ route : string | null ;
97+ };
98+ ```
2499
25100## Contributing
26101
0 commit comments