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: docs/api/framework-conventions/routes.ts.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
@@ -42,7 +42,7 @@ You can use the following helpers to create route config entries:
42
42
-[`route`][route] — Helper function for creating a route config entry
43
43
-[`index`][index] — Helper function for creating a route config entry for an index route
44
44
-[`layout`][layout] — Helper function for creating a route config entry for a layout route
45
-
-[`prefix`][prefix] — Helper function for adding a path prefix to a set of routes without needing to introduce a parent route file
45
+
-[`prefix`][prefix] — Helper function for adding a path prefix to a set of routes without needing to introduce a parent route
46
46
-[`relative`][relative] — Creates a set of route config helpers that resolve file paths relative to the given directory. Designed to support splitting route config into multiple files within different directories
Copy file name to clipboardExpand all lines: docs/start/framework/routing.md
+19-1Lines changed: 19 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -204,7 +204,7 @@ Note that index routes can't have children.
204
204
205
205
## Route Prefixes
206
206
207
-
Using `prefix`, you can add a path prefix to a set of routes without needing to introduce a parent route file.
207
+
Using `prefix`, you can add a path prefix to a set of routes without needing to introduce a parent route.
208
208
209
209
```tsx filename=app/routes.ts lines=[14]
210
210
import {
@@ -230,6 +230,24 @@ export default [
230
230
] satisfiesRouteConfig;
231
231
```
232
232
233
+
Note that this does not introduce a new route into the route tree. Instead, it merely modifies the paths of its children.
234
+
235
+
For example, these two sets of routes are equivalent:
236
+
237
+
```ts filename=app/routes.ts
238
+
// This usage of `prefix`...
239
+
prefix("parent", [
240
+
route("child1", "./child1.tsx"),
241
+
route("child2", "./child2.tsx"),
242
+
])
243
+
244
+
// ...is equivalent to this:
245
+
[
246
+
route("parent/child1", "./child1.tsx"),
247
+
route("parent/child2", "./child2.tsx"),
248
+
]
249
+
```
250
+
233
251
## Dynamic Segments
234
252
235
253
If a path segment starts with `:` then it becomes a "dynamic segment". When the route matches the URL, the dynamic segment will be parsed from the URL and provided as `params` to other router APIs.
0 commit comments