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/from-expo-router.md
+16-7Lines changed: 16 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,7 +66,11 @@ React Navigation starts with the navigation tree:
66
66
67
67
## Migration checklist
68
68
69
-
1. Remove Expo Router as the entry point.
69
+
1. Install React Navigation.
70
+
71
+
Follow the [Getting started](getting-started.md) guide to install React Navigation and the dependencies used by the navigators you need.
72
+
73
+
2. Remove Expo Router as the entry point.
70
74
71
75
If your app uses [`expo-router/entry`](https://docs.expo.dev/router/installation) in `package.json`, replace it with your app's entry file. If you don't use Expo Router anywhere else, remove the `expo-router` package and the `expo-router` config plugin from your Expo app config.
72
76
@@ -85,7 +89,7 @@ React Navigation starts with the navigation tree:
85
89
registerRootComponent(App);
86
90
```
87
91
88
-
2. Create a root navigator.
92
+
3. Create a root navigator.
89
93
90
94
Define your root navigator with a `createXNavigator` function, create screen configs with the matching [`createXScreen`](static-configuration.md#createxscreen) helper, and render it with [`createStaticNavigation`](static-configuration.md#createstaticnavigation):
91
95
@@ -120,7 +124,7 @@ React Navigation starts with the navigation tree:
120
124
}
121
125
```
122
126
123
-
3. Move each route file into a screen registration.
127
+
4. Move each route file into a screen registration.
124
128
125
129
A route file such as `app/profile/[userId].tsx` becomes a screen component registered in a navigator. Keep the component code, but replace Expo Router hooks with React Navigation's [`useRoute`](use-route.md) (or `route` prop) and [`useNavigation`](use-navigation.md) hooks.
126
130
@@ -142,7 +146,7 @@ React Navigation starts with the navigation tree:
142
146
}
143
147
```
144
148
145
-
4. Recreate `_layout.tsx` files with nested navigators.
149
+
5. Recreate `_layout.tsx` files with nested navigators.
146
150
147
151
A layout returning `<Stack />` becomes [`createNativeStackNavigator`](native-stack-navigator.md) or [`createStackNavigator`](stack-navigator.md), `<Tabs />` becomes [`createBottomTabNavigator`](bottom-tab-navigator.md), `<NativeTabs />` becomes [`createNativeBottomTabNavigator`](native-bottom-tab-navigator.md), and `<Drawer />` becomes [`createDrawerNavigator`](drawer-navigator.md). Nested layout files become [nested navigators](nesting-navigators.md).
148
152
@@ -167,7 +171,7 @@ React Navigation starts with the navigation tree:
167
171
});
168
172
```
169
173
170
-
5. Recreate URLs with linking configuration.
174
+
6. Recreate URLs with linking configuration.
171
175
172
176
Expo Router infers paths from file names. React Navigation [generates paths automatically based on screen names](configuring-links.md#how-does-automatic-path-generation-work), and you can override paths with the `linking` property on a screen for custom patterns.
173
177
@@ -186,7 +190,7 @@ React Navigation starts with the navigation tree:
186
190
187
191
For example, Expo Router's `app/profile/[userId].tsx` can become a root stack screen with `linking: 'profile/:userId'`.
188
192
189
-
6. Replace redirects and protected routes.
193
+
7. Replace redirects and protected routes.
190
194
191
195
Replace [`Redirect`](https://docs.expo.dev/versions/latest/sdk/router/link#redirect) and [protected route groups](https://docs.expo.dev/router/advanced/protected) with conditional screens or groups. In static configuration, use the [`if`](static-configuration.md#if) property described in the [authentication flow](auth-flow.md?config=static) guide. When the condition changes, screens that no longer match are removed from the navigation state.
192
196
@@ -205,7 +209,7 @@ React Navigation starts with the navigation tree:
205
209
});
206
210
```
207
211
208
-
7. Handle unmatched routes and deep links.
212
+
8. Handle unmatched routes and deep links.
209
213
210
214
Replace [`+not-found`](https://docs.expo.dev/router/error-handling/#unmatched-routes) with a screen that uses a catch-all linking path such as `'*'`. Replace [`+native-intent`](https://docs.expo.dev/router/advanced/native-intent) with [`getInitialURL` and `subscribe`](deep-linking.md#integrating-with-other-tools) in the [`linking`](navigation-container.md#linking) configuration.
211
215
@@ -248,6 +252,11 @@ React Navigation starts with the navigation tree:
|[`router.replace`](https://docs.expo.dev/versions/latest/sdk/router/#imperativerouter)|[`navigation.replace`](stack-actions.md#replace) in stack navigators |
|[`router.dismiss`](https://docs.expo.dev/versions/latest/sdk/router/#imperativerouter)|[`navigation.pop`](stack-actions.md#pop) in stack navigators |
257
+
|[`router.dismissTo`](https://docs.expo.dev/versions/latest/sdk/router/#imperativerouter)|[`navigation.popTo`](stack-actions.md#popto) in stack navigators |
258
+
|[`router.dismissAll`](https://docs.expo.dev/versions/latest/sdk/router/#imperativerouter)|[`navigation.popToTop`](stack-actions.md#poptotop) in stack navigators |
259
+
|[`router.canDismiss`](https://docs.expo.dev/versions/latest/sdk/router/#imperativerouter)|[`navigation.canGoBack`](navigation-object.md#cangoback) in stack navigators |
251
260
|[`router.setParams`](https://docs.expo.dev/versions/latest/sdk/router/#imperativerouter)|[`navigation.setParams`](navigation-object.md#setparams) and [`navigation.replaceParams`](navigation-actions.md#replaceparams)|
Copy file name to clipboardExpand all lines: versioned_docs/version-8.x/from-expo-router.md
+21-8Lines changed: 21 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,7 +67,13 @@ React Navigation starts with the navigation tree:
67
67
68
68
## Migration checklist
69
69
70
-
1. Remove Expo Router as the entry point.
70
+
1. Install React Navigation.
71
+
72
+
Follow the [Getting started](getting-started.md) guide to install React Navigation and the dependencies used by the navigators you need.
73
+
74
+
If your app runs in [Expo Go](https://expo.dev/go), you'll also need to switch to a [development build](https://docs.expo.dev/development/introduction/), since Expo Go doesn't support React Navigation 8.
75
+
76
+
2. Remove Expo Router as the entry point.
71
77
72
78
If your app uses [`expo-router/entry`](https://docs.expo.dev/router/installation) in `package.json`, replace it with your app's entry file. If you don't use Expo Router anywhere else, remove the `expo-router` package and the `expo-router` config plugin from your Expo app config.
73
79
@@ -86,7 +92,7 @@ React Navigation starts with the navigation tree:
86
92
registerRootComponent(App);
87
93
```
88
94
89
-
2. Create a root navigator.
95
+
3. Create a root navigator.
90
96
91
97
Define your root navigator with a `createXNavigator` function, create screen configs with the matching [`createXScreen`](static-configuration.md#createxscreen) helper, and render it with [`createStaticNavigation`](static-configuration.md#createstaticnavigation):
92
98
@@ -121,7 +127,7 @@ React Navigation starts with the navigation tree:
121
127
}
122
128
```
123
129
124
-
3. Move each route file into a screen registration.
130
+
4. Move each route file into a screen registration.
125
131
126
132
A route file such as `app/profile/[userId].tsx` becomes a screen component registered in a navigator. Keep the component code, but replace Expo Router hooks with React Navigation hooks such as [`useRoute`](use-route.md) and [`useNavigation`](use-navigation.md).
127
133
@@ -145,7 +151,7 @@ React Navigation starts with the navigation tree:
145
151
}
146
152
```
147
153
148
-
4. Recreate `_layout.tsx` files with nested navigators.
154
+
5. Recreate `_layout.tsx` files with nested navigators.
149
155
150
156
A layout returning `<Stack />` becomes [`createNativeStackNavigator`](native-stack-navigator.md) or [`createStackNavigator`](stack-navigator.md), `<Tabs />` becomes [`createBottomTabNavigator`](bottom-tab-navigator.md), and `<Drawer />` becomes [`createDrawerNavigator`](drawer-navigator.md). Nested layout files become [nested navigators](nesting-navigators.md).
151
157
@@ -170,7 +176,7 @@ React Navigation starts with the navigation tree:
170
176
});
171
177
```
172
178
173
-
5. Recreate URLs with linking configuration.
179
+
6. Recreate URLs with linking configuration.
174
180
175
181
Expo Router infers paths from file names. React Navigation [generates paths automatically based on screen names](configuring-links.md#how-does-automatic-path-generation-work), and you can override paths with the `linking` property on a screen for custom patterns.
176
182
@@ -189,7 +195,9 @@ React Navigation starts with the navigation tree:
189
195
190
196
For example, Expo Router's `app/profile/[userId].tsx` can become a root stack screen with `linking: 'profile/:userId'`.
191
197
192
-
6. Replace redirects and protected routes.
198
+
[Shared routes](https://docs.expo.dev/router/advanced/shared-routes) - defined with array syntax in group names such as `(feed,search)` - don't need an equivalent configuration. When the same screen is used in multiple navigators, React Navigation automatically treats its path as [shared](configuring-links.md#shared-paths), so all of them use a single URL. Expo Router targets a specific copy by including the group in the URL, e.g. `/(search)/profile/jane`. React Navigation has no such segment - opening `/profile/jane` keeps the current tab focused and opens `Profile` in that tab.
199
+
200
+
7. Replace redirects and protected routes.
193
201
194
202
Replace [`Redirect`](https://docs.expo.dev/versions/latest/sdk/router/link#redirect) and [protected route groups](https://docs.expo.dev/router/advanced/protected) with conditional screens or groups. In static configuration, use the [`if`](static-configuration.md#if) property described in the [authentication flow](auth-flow.md?config=static) guide. When the condition changes, screens that no longer match are removed from the navigation state.
195
203
@@ -208,7 +216,7 @@ React Navigation starts with the navigation tree:
208
216
});
209
217
```
210
218
211
-
7. Handle unmatched routes and deep links.
219
+
8. Handle unmatched routes and deep links.
212
220
213
221
Replace [`+not-found`](https://docs.expo.dev/router/error-handling/#unmatched-routes) with a screen that uses a catch-all linking path such as `'*'`. Replace [`+native-intent`](https://docs.expo.dev/router/advanced/native-intent) with [`getInitialURL` and `subscribe`](deep-linking.md#integrating-with-other-tools) in the [`linking`](navigation-container.md#linking) configuration.
214
222
@@ -251,6 +259,11 @@ React Navigation starts with the navigation tree:
|[`router.replace`](https://docs.expo.dev/versions/latest/sdk/router/#imperativerouter)|[`navigation.replace`](stack-actions.md#replace) in stack navigators |
|[`router.dismiss`](https://docs.expo.dev/versions/latest/sdk/router/#imperativerouter)|[`navigation.pop`](stack-actions.md#pop) in stack navigators |
264
+
|[`router.dismissTo`](https://docs.expo.dev/versions/latest/sdk/router/#imperativerouter)|[`navigation.popTo`](stack-actions.md#popto) in stack navigators |
265
+
|[`router.dismissAll`](https://docs.expo.dev/versions/latest/sdk/router/#imperativerouter)|[`navigation.popToTop`](stack-actions.md#poptotop) in stack navigators |
266
+
|[`router.canDismiss`](https://docs.expo.dev/versions/latest/sdk/router/#imperativerouter)|[`navigation.canGoBack`](navigation-object.md#cangoback) in stack navigators |
254
267
|[`router.setParams`](https://docs.expo.dev/versions/latest/sdk/router/#imperativerouter)|[`navigation.setParams`](navigation-object.md#setparams), [`navigation.replaceParams`](navigation-actions.md#replaceparams) and [`navigation.pushParams`](navigation-actions.md#pushparams)|
|[`useSitemap`](https://docs.expo.dev/versions/latest/sdk/router/#usesitemap)| No direct equivalent. |
264
-
|[`useLoaderData`](https://docs.expo.dev/router/web/data-loaders)| No direct equivalent, but planned. |
277
+
|[`useLoaderData`](https://docs.expo.dev/router/web/data-loaders)| No equivalent hook. A screen can define a [loader](data-loading.md) to start fetching on navigation, and read the data from your data fetching library.|
0 commit comments