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
docs: refactor example apps and installation guide (#67)
* docs: update readme for expo bare and router examples
* refactor: improve clarity and conciseness of README examples
* refactor: update readme deferred flow instructions
* Revert "refactor: update readme deferred flow instructions"
This reverts commit d703c8c.
* docs: add deferred deep link example
* docs: update example link handling descriptions
* docs: add screenshots to expo-bare example
* refactor: update app.json bundle identifiers and domain
* docs: update screenshot paths in expo-bare example
* docs: update expo bare example readme
* docs: update bare expo readme example
* docs: improve example readme descriptions
* docs: update readme examples for detour
* docs: update readme with new screenshots and clarify flow
* refactor: extract LinkTestingCard component
* docs: update expo-router native intent example
* chore: update screenshots in intent example
* docs: update react-navigation example screenshots and text
* refactor: remove unused screenshot notes
* docs: clarify link handling in examples
* feat: add bare react native cli example
* docs: add bare react native cli setup instructions
* refactor: remove bare-react-native-cli example
> 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.
46
46
47
+
### Bare React Native CLI (without Expo)
48
+
49
+
Detour's peer dependencies are Expo Modules (they ship native code). In a bare React Native CLI project, add Expo Modules once and point Metro at `expo/metro-config`:
Then rebuild — `DetourProvider` and the hooks work exactly as in the Expo examples.
65
+
66
+
See [Expo Modules setup](https://detour.swmansion.com/docs/sdk/react-native/sdk-installation#expo-modules-setup-react-native-cli) for the full walkthrough, and [build issues](https://detour.swmansion.com/docs/sdk/react-native/testing#bare-react-native-cli-build-issues) if you hit setup errors.
67
+
47
68
## Usage
48
69
49
70
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.
This example demonstrates a simple integration of `@swmansion/react-native-detour` in a React Native app.
3
+
The most minimal integration of [`@swmansion/react-native-detour`](https://detour.swmansion.com/docs/sdk/react-native/sdk-installation) — no router, no navigation library. `DetourProvider` is initialized with SDK config and a single screen renders the raw `useDetourContext()` state. No router or navigation.
4
4
5
-
## Scenario represented
5
+
Use this as a quick SDK smoke test or as a base before adding your own routing.
6
6
7
-
-`DetourProvider` is initialized with SDK config.
8
-
- A single screen consumes `useDetourContext()`.
9
-
- No router/navigation integration is implemented here.
10
-
- The example is focused on exposing Detour link state.
- Base starting point before adding your own navigation/deep-link routing logic.
13
+
## Test flow
17
14
18
-
If you need more complex routing flows with a specific navigation library, check out the following examples:
15
+
Launch the app — once the startup check completes, `isLinkProcessed` turns `true`. With no pending link, `type`, `url`, and `route` are empty.
19
16
20
-
-`examples/expo-router`
21
-
-`examples/expo-router-advanced`
22
-
-`examples/react-navigation`
17
+
Trigger a Universal/App link (see [Triggering links](#triggering-links)) — `type`, `url`, and `route` populate with the resolved link data.
23
18
24
-
## Test flow
19
+
To test the **deferred** case: follow the [Deferred deep link](#triggering-links) setup before installing. The deferred check only runs once - the SDK writes a persistent flag on first launch, so subsequent launches skip it. Reinstalling is needed to re-trigger the deferred path.
20
+
21
+
A **custom-scheme** link (`detour-expo-bare://details`) populates the same `type`, `url`, and `route` fields (with `type: scheme`) — see [Triggering links](#triggering-links).
22
+
23
+
<br>
24
+
<imgsrc="assets/screenshots/app-resolved.png"alt="Resolved Detour link state"width="50%"/>
25
+
<br>
26
+
27
+
> _**Resolved link state**. The screen after a Detour link is resolved with `isLinkProcessed: true` and `type`, `url`, and `route` filled in._
28
+
29
+
## Set up Detour
30
+
31
+
You need a Detour account to register this app and generate its credentials. [Sign up](https://godetour.dev/auth/signup) and open the [Detour Dashboard](https://godetour.dev). If you run into issues during setup, the [Dashboard Walkthrough](https://detour.swmansion.com/docs/Fundamentals/dashboard) covers each step in detail.
32
+
33
+
### 1. Register the app
34
+
35
+
Create an organization and add a new app. Detour assigns it a base link URL of the form `https://<your-org>.godetour.link/<your-app-hash>` visible in **Link settings** section.
36
+
37
+
> In **Link settings**, the dashboard asks for a fallback Redirect URL to mark setup as complete. It only controls where **web** traffic lands — it has no effect on the deferred or Universal/App link flows these examples test, so it can be left empty or filled with a placeholder URL for local development. For production, see [Full app configuration](https://detour.swmansion.com/docs/Fundamentals/getting-started#4-complete-app-configuration).
<imgsrc="assets/screenshots/dashboard-create-app-c.png"alt="Detour Dashboard app link details"/>
47
+
<br>
48
+
49
+
> **Dashboard**. _Create an organization (top-left), create a new app (top-right), and use the generated link (marked with red) in Link settings (bottom)._
50
+
51
+
52
+
### 2. Configure the platforms
53
+
54
+
Open **App configuration** and fill in the platform details:
55
+
56
+
-**iOS:** set Bundle ID to `detourreactnative.expobare` and provide Team ID and App Store ID. The **Team ID must be your real Apple Developer Team ID** — the one the build is signed with (`DEVELOPMENT_TEAM` in Xcode › Signing & Capabilities, also shown under [Apple Developer › Membership](https://developer.apple.com/account)). A placeholder or mismatched Team ID makes the Universal link open in Safari instead of the app. The App Store ID can stay a placeholder for local development.
57
+
-**Android:** set package name to `detourreactnative.expobare` and add a SHA-256 certificate fingerprint. The **fingerprint must match the keystore that signs the build** — a wrong value makes Android open the App link in the browser instead of the app. For local development (`npx expo run:android`), use the **local debug keystore** fingerprint. See [Testing Android App Links](https://detour.swmansion.com/docs/sdk/react-native/testing#testing-android-app-links) for more info.
58
+
59
+
The dashboard generates the `associatedDomains` and intent-filter snippets to paste into `app.json` ([below](#configuring-appjson)).
60
+
61
+
> For a production integration, fill all fields with real values. See [App configuration](https://detour.swmansion.com/docs/Fundamentals/getting-started#app-configuration) for full guidance.
> **Dashboard › App configuration**. _iOS and Android filled configurations with generated integration code snippets ready to copy._
25
69
26
-
1. Start the app on iOS/Android.
27
-
2. Confirm the app renders and `isLinkProcessed` is `false`.
28
-
3. Trigger a Detour link.
29
-
4. Confirm `isLinkProcessed` flips to `true` and `type`, `url`, and `route` fields are populated on screen.
70
+
### 3. Copy your credentials
71
+
72
+
Open **API configuration** and copy your `appID` and publishable `apiKey` into this example's `.env`.
73
+
74
+
→ [Dashboard › API configuration](https://detour.swmansion.com/docs/Fundamentals/dashboard#api-configuration-and-key-security)
75
+
76
+
<imgsrc="assets/screenshots/dashboard-api-configuration.png"alt="Detour Dashboard API configuration"/>
77
+
<br>
78
+
79
+
> **Dashboard › API configuration**. _The API configuration panel with `appID` and the publishable `apiKey` ready to copy._
30
80
31
81
## Configuring app.json
32
82
33
-
After registering your app in the [Detour Dashboard](https://godetour.dev), replace the placeholders in `app.json` with values from the **API configuration** section:
83
+
Replace the placeholders in `app.json` with the values from the dashboard's [App configuration](https://detour.swmansion.com/docs/Fundamentals/dashboard#app-configuration) section:
34
84
35
85
-`<your-org>` — your organization slug
36
86
-`<your-app-hash>` — the path prefix assigned to your app
These same values go into the simulator commands in the section below.
102
+
> **Universal Links not opening the app?** Add `?mode=developer` to the `associatedDomains` entry: `"applinks:<your-org>.godetour.link?mode=developer"`. This bypasses Apple's CDN and fetches the AASA file directly from your domain on every launch instead of relying on a potentially stale cached version. Requires **Settings → Developer → Associated Domains Development** to be enabled on the device and a development-signed build. Remove it before submitting to TestFlight or the App Store.
103
+
104
+
These same values go into the simulator commands in the next section.
52
105
53
106
## Triggering links
54
107
55
-
**Universal / App link** — open a Detour HTTPS link:
108
+
<details>
109
+
<summary>Deferred deep link</summary>
110
+
111
+
Follow these steps to test the deferred flow:
112
+
113
+
1. Uninstall the app or clear its data to start from a clean state.
114
+
2. Open a Detour link in the device's mobile browser.
115
+
3. Install and launch the app — the SDK resolves the link automatically.
116
+
117
+
> **Note:** On Android, the install referrer is typically unavailable in development builds, so deferred matching falls back to probabilistic signals (IP, device fingerprint) only. See [Limitations & Known Issues](https://detour.swmansion.com/docs/Architecture/architecture-limitations).
118
+
119
+
Alternatively on iOS, you can also copy the link to your clipboard before uninstalling — the SDK reads the clipboard on first launch (`shouldUseClipboard: true`), so you can skip the browser step. It simulates a link clicked before the app was installed.
adb shell am start -a android.intent.action.VIEW -d "https://<your-org>.godetour.link/<your-app-hash>/"
63
134
```
64
135
65
-
**Deferred link** — simulates a link clicked before the app was installed:
136
+
Alternatively, paste the link into Notes or Messages on the device and tap it — this uses the same OS routing path a real user would.
66
137
67
-
1. Copy a Detour link URL from the Dashboard to your clipboard.
68
-
2. Kill or uninstall the app.
69
-
3. Relaunch — the SDK reads the clipboard on startup and resolves the link automatically.
138
+
</details>
139
+
140
+
<details>
141
+
<summary>Custom scheme</summary>
142
+
143
+
```sh
144
+
# iOS simulator
145
+
npx uri-scheme open "detour-expo-bare://details" --ios
146
+
147
+
# Android emulator
148
+
npx uri-scheme open "detour-expo-bare://details" --android
149
+
```
150
+
151
+
</details>
152
+
153
+
For more cases and gotchas, see [Testing & Troubleshooting](https://detour.swmansion.com/docs/sdk/react-native/testing).
70
154
71
155
## Quick start
72
156
73
157
- Install dependencies from the repo root: `pnpm install`
74
-
- Configure this app in Detour Dashboard: `https://godetour.dev` using identifiers from `app.json` (for example `ios.bundleIdentifier`, `android.package`).
75
-
- Use values from Dashboard from "API configuration" section to fill `.env` and update `app.json` with generated integration code.
158
+
- Configure this app in the [Detour Dashboard](https://godetour.dev) using identifiers from `app.json` (for example `ios.bundleIdentifier`, `android.package`).
159
+
- Use the values from the dashboard's [API configuration](https://detour.swmansion.com/docs/Fundamentals/dashboard#api-configuration-and-key-security) section to fill `.env` and update `app.json` with the generated integration code.
76
160
- Run prebuild for this example: `pnpm prebuild`
77
161
- Start the example: `pnpm start`
78
162
- Run on device/simulator: `pnpm ios` or `pnpm android`
163
+
164
+
## See also
165
+
166
+
-[SDK Usage](https://detour.swmansion.com/docs/sdk/react-native/sdk-usage) — how to integrate Detour with your navigation library
167
+
-[API Reference](https://detour.swmansion.com/docs/sdk/react-native/api-reference) — full type and method reference
0 commit comments