Skip to content
Source
Sign inSign up
TanStack/router

fix(start): pass raw path params to server route handlers #8638

OpenSheraff(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromfix/server-route-raw-paramsopened

Showing 12 changed files with 39 additions and 1 deletion (loading 8).

x
0 of 12 viewed, 12 left
6 additions and 0 deletions.changeset/server-route-raw-params.mdAdded
View file
@@ -0,0 +1,6 @@
+---
+'@tanstack/start-client-core': patch
+'@tanstack/start-server-core': patch
+---
+​
+Server route handlers receive the raw string path params from the URL again, and their `params` type now says so. `params.parse` output is no longer applied to handler params, so a `params.parse` that throws (including `notFound()`) no longer turns server route requests into 500 errors. Handlers can call `next()` to let the router render the page with parsed params.
2 additions and 0 deletionsdocs/router/api/router/RouteOptionsType.mdModified
View file
@@ -84,6 +84,8 @@
- Type: `(rawParams: Record<string, string>) => TParams | false`
- Optional
- 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.
+- Throwing `notFound()` or `redirect()` from this function is handled like throwing them from `beforeLoad`: the route renders its not-found state or the router redirects.
+- TanStack Start server route handlers receive the raw params, not this function's output.
- This is a planning callback. It must be deterministic and side-effect-free for the same input.
- Experimental: returning `false` during incoming route matching skips this route and allows matching to continue to another candidate route.
​
31 additions and 1 deletiondocs/start/framework/react/guide/server-routes.mdModified
View file
@@ -243,7 +243,7 @@