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
Copy file name to clipboardExpand all lines: versioned_docs/version-7.x/deep-linking.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ This guide will describe how to configure your app to handle deep links on vario
14
14
15
15
React Native provides a [`Linking`](https://reactnative.dev/docs/linking) to get notified of incoming links. React Navigation can integrate with the `Linking` module to automatically handle deep links. On Web, React Navigation can integrate with browser's `history` API to handle URLs on client side. See [configuring links](configuring-links.md) to see more details on how to configure links in React Navigation.
16
16
17
-
While you don't need to use the `linking` prop from React Navigation, and can handle deep links yourself by using the `Linking` API and navigating from there, it'll be significantly more complicated than using the `linking` prop which handles many edge cases for you. So we don't recommend implementing it by yourself.
17
+
We don't recommend handling deep links yourself using a [`ref`](navigation-container.md#ref) as it can be error-prone and significantly more complicated. Using the `linking` prop is the recommended way to handle deep links in React Navigation.
18
18
19
19
Below, we'll go through required configurations so that the deep link integration works.
Copy file name to clipboardExpand all lines: versioned_docs/version-7.x/web-support.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ While Web support works out of the box, there are some things to configure to en
15
15
16
16
1.[**Configure linking**](configuring-links.md)
17
17
18
-
Configuring linking allows React Navigation to integrate with the browser's URL bar. This is crucial for web apps to have proper URLs for each screen.
18
+
Configuring linking allows React Navigation to integrate with the browser's URL bar, using the same configuration as for deep linking in React Native. This is crucial for web apps to have proper URLs for each screen.
Copy file name to clipboardExpand all lines: versioned_docs/version-8.x/deep-linking.md
+6-54Lines changed: 6 additions & 54 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ This guide will describe how to configure your app to handle deep links on vario
14
14
15
15
React Native provides a [`Linking`](https://reactnative.dev/docs/linking) to get notified of incoming links. React Navigation can integrate with the `Linking` module to automatically handle deep links. On Web, React Navigation can integrate with browser's `history` API to handle URLs on client side. See [configuring links](configuring-links.md) to see more details on how to configure links in React Navigation.
16
16
17
-
While you don't need to use the `linking` prop from React Navigation, and can handle deep links yourself by using the `Linking` API and navigating from there, it'll be significantly more complicated than using the `linking` prop which handles many edge cases for you. So we don't recommend implementing it by yourself.
17
+
We don't recommend handling deep links yourself using a [`ref`](navigation-container.md#ref) as it can be error-prone and significantly more complicated. Using the `linking` prop is the recommended way to handle deep links in React Navigation.
18
18
19
19
Below, we'll go through required configurations so that the deep link integration works.
20
20
@@ -56,9 +56,9 @@ See more details below at [Configuring React Navigation](#configuring-react-navi
56
56
<details>
57
57
<summary>Why use `Linking.createURL`?</summary>
58
58
59
-
It is necessary to use `Linking.createURL` since the scheme differs between the [Expo Dev Client](https://docs.expo.dev/versions/latest/sdk/dev-client/) and standalone apps.
59
+
It is necessary to use `Linking.createURL` since the scheme differs between the [Expo Go](https://expo.dev/go) and standalone apps.
60
60
61
-
The scheme specified in `app.json` only applies to standalone apps. In the Expo client app you can deep link using `exp://ADDRESS:PORT/--/` where `ADDRESS` is often `127.0.0.1` and `PORT` is often `19000` - the URL is printed when you run `expo start`. The `Linking.createURL` function abstracts it out so that you don't need to specify them manually.
61
+
The scheme specified in `app.json` only applies to standalone apps. In the Expo client (Expo Go or Dev Client) app you can deep link using `exp://ADDRESS:PORT/--/` where `ADDRESS` is often `127.0.0.1` and `PORT` is often `19000` - the URL is printed when you run `expo start`. The `Linking.createURL` function abstracts it out so that you don't need to specify them manually.
62
62
63
63
</details>
64
64
@@ -283,55 +283,11 @@ Then, you need to [declare the association](https://developer.android.com/traini
283
283
284
284
## Configuring React Navigation
285
285
286
-
To handle deep links, you need to configure React Navigation to use the `scheme` for parsing incoming deep links:
286
+
To handle deep links, you need to configure React Navigation based on the API you're using.
287
287
288
-
<TabsgroupId="config"queryString="config">
289
-
<TabItemvalue="static"label="Static"default>
290
-
291
-
```js
292
-
constlinking= {
293
-
prefixes: [
294
-
'example://', // Or `Linking.createURL('/')` for Expo apps
295
-
],
296
-
};
297
-
298
-
functionApp() {
299
-
return<Navigation linking={linking} />;
300
-
}
301
-
```
302
-
303
-
</TabItem>
304
-
<TabItemvalue="dynamic"label="Dynamic">
305
-
306
-
```js
307
-
constlinking= {
308
-
prefixes: [
309
-
'example://', // Or `Linking.createURL('/')` for Expo apps
For static configuration, deep links are enabled by default with automatic path generation. So no additional configuration is needed. You can optionally customize the path patterns for specific screens if needed.
321
289
322
-
</TabItem>
323
-
</Tabs>
324
-
325
-
If you are using universal links, you need to add your domain to the prefixes as well:
326
-
327
-
```js
328
-
constlinking= {
329
-
prefixes: [
330
-
'example://', // Or `Linking.createURL('/')` for Expo apps
331
-
'https://app.example.com',
332
-
],
333
-
};
334
-
```
290
+
For dynamic configuration, deep links are enabled if you provide a `linking` prop to the `NavigationContainer`. The `linking` prop should contain mappings between path patterns and screens.
335
291
336
292
See [configuring links](configuring-links.md) to see further details on how to configure links in React Navigation.
337
293
@@ -422,8 +378,6 @@ Here is an example integration with [expo-notifications](https://docs.expo.dev/v
Copy file name to clipboardExpand all lines: versioned_docs/version-8.x/navigation-container.md
+4-11Lines changed: 4 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -514,13 +514,16 @@ function App() {
514
514
515
515
</TabItem>
516
516
</Tabs>
517
+
517
518
See [configuring links guide](configuring-links.md) for more details on how to configure deep links and URL integration.
518
519
519
520
#### Options
520
521
521
522
##### `linking.prefixes`
522
523
523
-
URL prefixes to handle. You can provide multiple prefixes to support custom schemes as well as [universal links](https://developer.apple.com/ios/universal-links/).
524
+
Optional URL prefixes to handle. By default, it matches any host starting with `http`, `https`, and custom schemes such as `myapp://` if this option is not specified.
525
+
526
+
You can provide multiple prefixes to support custom schemes as well as [universal links](https://developer.apple.com/ios/universal-links/) to explicitly handle certain prefixes.
524
527
525
528
Only URLs matching these prefixes will be handled. The prefix will be stripped from the URL before parsing.
526
529
@@ -591,7 +594,6 @@ import messaging from '@react-native-firebase/messaging';
591
594
592
595
<Navigation
593
596
linking={{
594
-
prefixes: ['https://example.com', 'example://'],
595
597
// highlight-start
596
598
asyncgetInitialURL() {
597
599
// Check if app was opened from a deep link
@@ -621,7 +623,6 @@ import messaging from '@react-native-firebase/messaging';
621
623
622
624
<NavigationContainer
623
625
linking={{
624
-
prefixes: ['https://example.com', 'example://'],
625
626
config: {
626
627
// ...
627
628
},
@@ -667,7 +668,6 @@ import messaging from '@react-native-firebase/messaging';
Copy file name to clipboardExpand all lines: versioned_docs/version-8.x/static-configuration.md
+3-4Lines changed: 3 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -366,14 +366,13 @@ Similar to `NavigationContainer`, the component returned by `createStaticNavigat
366
366
367
367
1. It's not possible to pass a full `config` object to the `linking` prop. It can only accept [`path`](configuring-links.md#apps-under-subpaths) and an [`initialRouteName` for the root navigator](configuring-links.md#rendering-an-initial-route).
368
368
2. The linking config is collected from the [`linking`](#linking) properties specified in the screen configuration.
369
-
3. It's possible to pass `enabled: 'auto'`to automatically generate paths for all leaf screens:
369
+
3. It defaults to `enabled: 'auto'`which enables deep links by default and automatically generate paths for all leaf screens.
@@ -383,4 +382,4 @@ Similar to `NavigationContainer`, the component returned by `createStaticNavigat
383
382
384
383
See [How does automatic path generation work](configuring-links.md#how-does-automatic-path-generation-work) for more details.
385
384
386
-
By default, linking is enabled in static configuration with automatic path generation. It needs to be explicitly disabled by passing `enabled: false` to the `linking` prop if you don't want linking support.
385
+
By default, linking is enabled in static configuration with automatic path generation. If you don't want linking support, it can be disabled by explicitly passing `enabled: false` to the `linking` prop.
Copy file name to clipboardExpand all lines: versioned_docs/version-8.x/web-support.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ While Web support works out of the box, there are some things to configure to en
15
15
16
16
1.[**Configure linking**](configuring-links.md)
17
17
18
-
Configuring linking allows React Navigation to integrate with the browser's URL bar. This is crucial for web apps to have proper URLs for each screen.
18
+
Configuring linking allows React Navigation to integrate with the browser's URL bar, using the same configuration as for deep linking in React Native. This is crucial for web apps to have proper URLs for each screen.
19
19
20
20
Automatic links are already enabled by default when using [Static configuration](static-configuration.md). So if you're using static configuration, you don't need to do anything to enable linking.
0 commit comments