Skip to content

Commit baee244

Browse files
Document prefix not introducing a new route (#14318)
1 parent f9a8b39 commit baee244

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

docs/api/framework-conventions/routes.ts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ You can use the following helpers to create route config entries:
4242
- [`route`][route] — Helper function for creating a route config entry
4343
- [`index`][index] — Helper function for creating a route config entry for an index route
4444
- [`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
4646
- [`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
4747

4848
### File-based Routing

docs/start/framework/routing.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ Note that index routes can't have children.
204204

205205
## Route Prefixes
206206

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.
208208

209209
```tsx filename=app/routes.ts lines=[14]
210210
import {
@@ -230,6 +230,24 @@ export default [
230230
] satisfies RouteConfig;
231231
```
232232

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+
233251
## Dynamic Segments
234252

235253
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

Comments
 (0)