Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d9e403b
feat(router-core): validate params while matching
Sheraff Nov 21, 2025
77aade6
Merge branch 'main' into feat-router-core-validate-params-while-matching
Sheraff Nov 26, 2025
2fd3009
more wip
Sheraff Nov 30, 2025
102ef3c
Merge branch 'main' into feat-router-core-validate-params-while-matching
Sheraff Nov 30, 2025
c9f0f62
Merge branch 'main' into feat-router-core-validate-params-while-matching
Sheraff Dec 20, 2025
b9c416a
introduce index node and pathless node
Sheraff Dec 21, 2025
9b08317
Merge branch 'main' into feat-router-core-validate-params-while-matching
Sheraff Dec 21, 2025
5e0ea27
merge typo
Sheraff Dec 21, 2025
fca20ce
more post-merge fixes
Sheraff Dec 21, 2025
c577ce9
don't handle regular parsing, only skip parsing
Sheraff Dec 21, 2025
0353059
fix sorting
Sheraff Dec 21, 2025
c67704e
format
Sheraff Dec 21, 2025
c221f3e
remove error from types, its currently unused
Sheraff Dec 22, 2025
1a3df20
format
Sheraff Dec 22, 2025
152a6bf
collect rawParams and parsedParams instead of just 'params'
Sheraff Dec 22, 2025
725b764
accumulating parsed params shouldn't mutate the branch, shallow copy …
Sheraff Dec 22, 2025
7f821bf
fix renaming
Sheraff Dec 22, 2025
c96fdc7
new skip API options
Sheraff Dec 23, 2025
8b78730
update snapshot
Sheraff Dec 23, 2025
6b9d31b
pathless nodes can match beyond path length
Sheraff Dec 23, 2025
c35ac00
ai generated tests, seem good, but should review more deeply
Sheraff Dec 23, 2025
cac7a3b
improve tests
Sheraff Dec 23, 2025
eed4b0b
docs
Sheraff Dec 24, 2025
40b9428
fix jsdoc
Sheraff Dec 24, 2025
086f196
Merge branch 'main' into feat-router-core-validate-params-while-matching
Sheraff Jan 7, 2026
5e9ffbc
docs: skipRouteOnParseError docs WIP
Sheraff Jan 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/router/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@
"label": "Path Params",
"to": "framework/react/guide/path-params"
},
{
"label": "Validating Path Params",
"to": "framework/react/guide/validating-path-params"
},
{
"label": "Search Params",
"to": "framework/react/guide/search-params"
Expand Down Expand Up @@ -354,6 +358,10 @@
"label": "Path Params",
"to": "framework/solid/guide/path-params"
},
{
"label": "Validating Path Params",
"to": "framework/solid/guide/validating-path-params"
},
{
"label": "Search Params",
"to": "framework/solid/guide/search-params"
Expand Down
21 changes: 21 additions & 0 deletions docs/router/framework/react/api/router/RouteOptionsType.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,27 @@ The `RouteOptions` type accepts an object with the following properties:
- Type: `(params: TParams) => Record<string, string>`
- A function that will be called when this route's parsed params are being used to build a location. This function should return a valid object of `Record<string, string>` mapping.

### `skipRouteOnParseError` property (⚠️ experimental)

> [!WARNING]
> The `skipRouteOnParseError` option is currently **experimental** and may change in future releases.

- Type:

```tsx
type skipRouteOnParseError = {
params?: boolean
priority?: number
}
```

- Optional
- By default, when a route's `params.parse` function throws an error, the route will match and then show an error state during render. With `skipRouteOnParseError.params` enabled, the router will skip routes whose `params.parse` function throws and continue searching for alternative matching routes.
- See [Guides > Path Params > Validating path parameters during matching](../../guide/path-params#validating-path-parameters-during-matching) for detailed usage examples.

> [!IMPORTANT]
> **Performance impact**: This option has a **non-negligible performance cost** and should only be enabled when needed. Routes with `skipRouteOnParseError` are placed on separate branches in the route matching tree instead of sharing nodes with other dynamic routes. This reduces the tree's ability to efficiently narrow down matches and requires testing more routes, even for routes that wouldn't match the path structure alone.

### `beforeLoad` method

- Type:
Expand Down
12 changes: 12 additions & 0 deletions docs/router/framework/react/guide/path-params.md
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,18 @@ function ShopComponent() {

Optional path parameters provide a powerful and flexible foundation for implementing internationalization in your TanStack Router applications. Whether you prefer prefix-based or combined approaches, you can create clean, SEO-friendly URLs while maintaining excellent developer experience and type safety.

## Validating and Transforming Path Parameters

Path parameters are captured from URLs as strings, but you often need to transform them to other types (numbers, dates) or validate they meet specific criteria (UUIDs, patterns). TanStack Router provides `params.parse` and `params.stringify` options for this purpose.

For a comprehensive guide on validating and transforming path parameters, including:

- Using `params.parse` to transform and validate parameters
- Understanding error handling with `errorComponent`
- Using the experimental `skipRouteOnParseError` feature for type-specific routes

See the dedicated [Validating Path Params](./validating-path-params.md) guide.

## Allowed Characters

By default, path params are escaped with `encodeURIComponent`. If you want to allow other valid URI characters (e.g. `@` or `+`), you can specify that in your [RouterOptions](../api/router/RouterOptionsType.md#pathparamsallowedcharacters-property).
Expand Down
Loading
Loading