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
{{ message }}
Repository navigation
Commit d533f87
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/router/api/router/RouteOptionsType.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,6 +84,14 @@ The `RouteOptions` type accepts an object with the following properties:
84
84
- A function that will be called when this route is matched and passed the raw params from the current location and return valid parsed params. If this function throws, the route will be put into an error state and the error will be thrown during render. If this function returns parsed params, its return value will be used as the route's params and the return type will be inferred into the rest of the router.
85
85
- Experimental: returning `false` during incoming route matching skips this route and allows matching to continue to another candidate route.
86
86
87
+
### `params.priority` property
88
+
89
+
- Type: `number`
90
+
- Optional
91
+
- Defaults to `0`
92
+
- Controls the matching order when multiple route candidates with `params.parse` can match the same URL segment. Higher numbers are tried first. If a higher-priority route's `params.parse` returns `false`, matching continues to the next candidate.
93
+
- This only affects competing candidates that use `params.parse`; normal route specificity still applies, so static routes continue to match before dynamic, optional, or wildcard routes.
Copy file name to clipboardExpand all lines: docs/router/guide/path-params.md
+23Lines changed: 23 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -131,6 +131,29 @@ function PostComponent() {
131
131
132
132
<!-- ::end:framework -->
133
133
134
+
## Prioritizing Parsed Path Param Routes
135
+
136
+
When multiple dynamic, optional, or wildcard routes can match the same URL, routes with `params.parse` are tried before equivalent routes without it. If multiple matching candidates use `params.parse`, you can use `params.priority` to control which candidate is tried first.
137
+
138
+
Higher `params.priority` values are tried first. The default priority is `0`, and if a higher-priority route's `params.parse` returns `false`, matching continues to the next candidate route.
With a fallback `/posts/$slug` route, `/posts/123` can match the parsed numeric route first, while `/posts/hello-world` can fall through to the slug route when `params.parse` returns `false`.
154
+
155
+
`params.priority` only affects competing candidates that use `params.parse`. It does not override normal route specificity, so static routes still match before dynamic, optional, or wildcard routes.
156
+
134
157
## Navigating with Path Params
135
158
136
159
When navigating to a route with path params, TypeScript will require you to pass the params either as an object or as a function that returns an object of params.
0 commit comments