fix(router-core): support parsed params in matchRoute #7776
main frommatch-route-parsed-params·opened matchRoute now resolves matches through the processed route tree.
- Applies route
params.parseresults before comparing or returning params. - Preserves parsed parent params for child parsers and handles repeated param names.
- Uses route precedence and parser rejection during matching, so lower-priority or rejected routes no longer match through raw path templates.
- Replaces
findSingleMatchand its cache withfindRouteMatch. - Normalizes exact trailing-slash matching while leaving fuzzy matching unchanged.
- Keeps
caseSensitive, basepath, search, pending, optional-param, and wildcard behavior covered.
matchRoute now returns false for destination templates that are not registered in the route tree.
Includes the reproducer from #2460.
Closes #2450.
Summary by CodeRabbit#
- Bug Fixes
- Fixed route matching to fully respect custom typed
params.parse/params.stringify, including proper numeric conversions. matchRoutenow returns parsed parameters (not raw strings) and correctly fails when typed parsing is rejected or throws.- Improved matching consistency across nested routes, including
searchand trailing-slash behavior.
- Fixed route matching to fully respect custom typed
- Tests
- Added/expanded
matchRouteanduseMatchRoutetest coverage for React, Solid, and Vue, covering typed params, fuzzy matching, and mismatch cases.
- Added/expanded
- Chores
- Added a patch changeset documenting the matching fix.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: react-router
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: router-core
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: solid-router
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: vue-router
View your CI Pipeline Execution ↗ for commit 7404bb0c95c904b7b268cb5236246b1e0bcb048e
Command Status Duration Result nx run-many --target=build --exclude=examples/*...✅ Succeeded 1m 47s View ↗
☁️ Nx Cloud last updated this comment at
2026-10-24 18:52:13UTC🚀 Changeset Version Preview#
1 package(s) bumped directly, 22 bumped as dependents.
🟩 Patch bumps#
Package Version Reason @tanstack/router-core1.171.39 → 1.171.40 Changeset @tanstack/react-router1.170.46 → 1.170.47 Dependent @tanstack/react-start1.169.4 → 1.169.5 Dependent @tanstack/react-start-client1.168.44 → 1.168.45 Dependent @tanstack/react-start-rsc0.1.65 → 0.1.66 Dependent @tanstack/react-start-server1.167.52 → 1.167.53 Dependent @tanstack/router-cli1.167.46 → 1.167.47 Dependent @tanstack/router-generator1.167.46 → 1.167.47 Dependent @tanstack/router-plugin1.168.48 → 1.168.49 Dependent @tanstack/router-vite-plugin1.167.48 → 1.167.49 Dependent @tanstack/solid-router1.170.43 → 1.170.44 Dependent @tanstack/solid-start1.169.4 → 1.169.5 Dependent @tanstack/solid-start-client1.168.42 → 1.168.43 Dependent @tanstack/solid-start-server1.167.50 → 1.167.51 Dependent @tanstack/start-client-core1.170.39 → 1.170.40 Dependent @tanstack/start-plugin-core1.171.55 → 1.171.56 Dependent @tanstack/start-server-core1.169.45 → 1.169.46 Dependent @tanstack/start-static-server-functions1.167.44 → 1.167.45 Dependent @tanstack/start-storage-context1.167.41 → 1.167.42 Dependent @tanstack/vue-router1.170.42 → 1.170.43 Dependent @tanstack/vue-start1.169.4 → 1.169.5 Dependent @tanstack/vue-start-client1.167.45 → 1.167.46 Dependent @tanstack/vue-start-server1.167.50 → 1.167.51 Dependent More templates
- tanstack-router-vue-example-basic-jsx
- tanstack-router-vue-example-basic-file-based-jsx
- tanstack-router-vue-example-basic-file-based-sfc
- tanstack-router-solid-example-authenticated-routes
- tanstack-router-solid-example-authenticated-routes-firebase
- tanstack-router-solid-example-basic
- tanstack-router-solid-example-basic-default-search-params
- tanstack-router-solid-example-basic-devtools-panel
- tanstack-router-solid-example-basic-file-based
- tanstack-router-solid-example-basic-non-nested-devtools
- tanstack-router-solid-example-basic-solid-query
- tanstack-router-solid-example-basic-solid-query-file-based
- tanstack-router-solid-example-basic-ssr-file-based
- tanstack-router-solid-example-basic-ssr-streaming-file-based
- tanstack-router-solid-example-basic-virtual-file-based
- tanstack-router-solid-example-basic-virtual-inside-file-based
- tanstack-router-solid-example-deferred-data
- tanstack-router-solid-i18n-paraglide
- tanstack-router-solid-example-kitchen-sink
- tanstack-router-solid-example-kitchen-sink-file-based
- tanstack-router-solid-example-kitchen-sink-solid-query
- tanstack-router-solid-example-kitchen-sink-solid-query-file-based
- tanstack-router-solid-example-large-file-based
- tanstack-router-solid-example-location-masking
- tanstack-router-solid-example-navigation-blocking
- tanstack-router-solid-example-quickstart
- tanstack-router-solid-example-quickstart-esbuild-file-based
- tanstack-router-solid-example-quickstart-file-based
- tanstack-router-solid-example-quickstart-rspack-file-based
- tanstack-router-solid-example-quickstart-webpack-file-based
- @tanstack/router-solid-mono-simple
- router-solid-mono-simple-lazy
- router-solid-monorepo-solid-query
- tanstack-router-solid-example-scroll-restoration
- tanstack-solid-router-search-validator-adapters
- tanstack-solid-start-example-basic
- tanstack-solid-start-example-basic-auth
- tanstack-solid-start-example-basic-authjs
- tanstack-solid-start-example-basic-cloudflare
- tanstack-solid-start-example-basic-netlify
- tanstack-solid-start-example-basic-nitro
- tanstack-start-example-basic-solid-query
- tanstack-solid-start-example-basic-static
- tanstack-solid-start-bun-hosting
- tanstack-solid-start-example-convex-better-auth
- tanstack-solid-start-example-counter
- tanstack-solid-start-i18n-paraglide
- tanstack-solid-start-example-large
- tanstack-solid-start-streaming-data-from-server-functions
- tanstack-solid-start-example-supabase-basic
- tanstack-solid-start-tailwind-v4
- tanstack-router-solid-example-view-transitions
- tanstack-router-solid-example-with-framer-motion
- tanstack-router-solid-example-with-trpc
- tanstack-router-react-example-authenticated-routes
- tanstack-router-react-example-authenticated-routes-firebase
- tanstack-router-react-example-basic
- tanstack-router-react-example-basic-default-search-params
- tanstack-router-react-example-basic-devtools-panel
- tanstack-router-react-example-basic-file-based
- tanstack-router-react-example-basic-non-nested-devtools
- tanstack-router-react-example-react-query
- tanstack-router-react-example-basic-react-query-file-based
- tanstack-router-react-example-basic-ssr-file-based
- tanstack-router-react-example-basic-ssr-streaming-file-based
- tanstack-router-react-example-basic-virtual-file-based
- tanstack-router-react-example-basic-virtual-inside-file-based
- tanstack-router-react-example-deferred-data
- tanstack-router-i18n-paraglide
- tanstack-router-react-example-kitchen-sink
- tanstack-router-react-example-kitchen-sink-file-based
- tanstack-router-react-example-kitchen-sink-react-query
- tanstack-router-react-example-kitchen-sink-react-query-file-based
- tanstack-router-react-example-large-file-based
- tanstack-router-react-example-location-masking
- tanstack-router-react-example-navigation-blocking
- tanstack-router-react-example-quickstart
- tanstack-router-react-example-quickstart-esbuild-file-based
- tanstack-router-react-example-quickstart-file-based
- tanstack-router-react-example-quickstart-rspack-file-based
- tanstack-router-react-example-quickstart-webpack-file-based
- router-monorepo-react-query
- router-mono-simple
- router-mono-simple-lazy
- tanstack-router-react-example-scroll-restoration
- tanstack-search-validator-adapters
- tanstack-start-example-bare
- tanstack-start-example-basic
- tanstack-start-example-basic-auth
- tanstack-router-react-example-basic-authjs
- tanstack-start-example-basic-cloudflare
- tanstack-start-example-basic-react-query
- tanstack-start-example-basic-rsbuild
- tanstack-start-example-basic-static
- tanstack-start-bun-hosting
- tanstack-start-example-clerk-basic
- tanstack-start-example-convex-trellaux
- tanstack-start-example-counter
- tanstack-start-i18n-paraglide
- tanstack-start-example-large
- tanstack-start-example-material-ui
- tanstack-start-example-next-migration
- tanstack-start-example-rscs
- tanstack-start-streaming-data-from-server-functions
- tanstack-start-example-supabase-basic
- tanstack-start-tailwind-v4
- tanstack-start-example-trellaux
- tanstack-start-example-workos
- tanstack-router-react-example-view-transitions
- tanstack-router-react-example-with-framer-motion
- tanstack-router-react-example-with-trpc
- tanstack-router-react-example-with-trpc-react-query
@tanstack/arktype-adapter
npm i https://pkg.pr.new/@tanstack/arktype-adapter@7776@tanstack/eslint-plugin-router
npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@7776@tanstack/eslint-plugin-start
npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@7776@tanstack/history
npm i https://pkg.pr.new/@tanstack/history@7776@tanstack/react-router
npm i https://pkg.pr.new/@tanstack/react-router@7776@tanstack/react-router-devtools
npm i https://pkg.pr.new/@tanstack/react-router-devtools@7776@tanstack/react-router-ssr-query
npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@7776@tanstack/react-start
npm i https://pkg.pr.new/@tanstack/react-start@7776@tanstack/react-start-client
npm i https://pkg.pr.new/@tanstack/react-start-client@7776@tanstack/react-start-rsc
npm i https://pkg.pr.new/@tanstack/react-start-rsc@7776@tanstack/react-start-server
npm i https://pkg.pr.new/@tanstack/react-start-server@7776@tanstack/router-cli
npm i https://pkg.pr.new/@tanstack/router-cli@7776@tanstack/router-core
npm i https://pkg.pr.new/@tanstack/router-core@7776@tanstack/router-devtools
npm i https://pkg.pr.new/@tanstack/router-devtools@7776@tanstack/router-devtools-core
npm i https://pkg.pr.new/@tanstack/router-devtools-core@7776@tanstack/router-generator
npm i https://pkg.pr.new/@tanstack/router-generator@7776@tanstack/router-plugin
npm i https://pkg.pr.new/@tanstack/router-plugin@7776@tanstack/router-ssr-query-core
npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@7776@tanstack/router-utils
npm i https://pkg.pr.new/@tanstack/router-utils@7776@tanstack/router-vite-plugin
npm i https://pkg.pr.new/@tanstack/router-vite-plugin@7776@tanstack/solid-router
npm i https://pkg.pr.new/@tanstack/solid-router@7776@tanstack/solid-router-devtools
npm i https://pkg.pr.new/@tanstack/solid-router-devtools@7776@tanstack/solid-router-ssr-query
npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@7776@tanstack/solid-start
npm i https://pkg.pr.new/@tanstack/solid-start@7776@tanstack/solid-start-client
npm i https://pkg.pr.new/@tanstack/solid-start-client@7776@tanstack/solid-start-server
npm i https://pkg.pr.new/@tanstack/solid-start-server@7776@tanstack/start-client-core
npm i https://pkg.pr.new/@tanstack/start-client-core@7776@tanstack/start-fn-stubs
npm i https://pkg.pr.new/@tanstack/start-fn-stubs@7776@tanstack/start-plugin-core
npm i https://pkg.pr.new/@tanstack/start-plugin-core@7776@tanstack/start-server-core
npm i https://pkg.pr.new/@tanstack/start-server-core@7776@tanstack/start-static-server-functions
npm i https://pkg.pr.new/@tanstack/start-static-server-functions@7776@tanstack/start-storage-context
npm i https://pkg.pr.new/@tanstack/start-storage-context@7776@tanstack/valibot-adapter
npm i https://pkg.pr.new/@tanstack/valibot-adapter@7776@tanstack/virtual-file-routes
npm i https://pkg.pr.new/@tanstack/virtual-file-routes@7776@tanstack/vue-router
npm i https://pkg.pr.new/@tanstack/vue-router@7776@tanstack/vue-router-devtools
npm i https://pkg.pr.new/@tanstack/vue-router-devtools@7776@tanstack/vue-router-ssr-query
npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@7776@tanstack/vue-start
npm i https://pkg.pr.new/@tanstack/vue-start@7776@tanstack/vue-start-client
npm i https://pkg.pr.new/@tanstack/vue-start-client@7776@tanstack/vue-start-server
npm i https://pkg.pr.new/@tanstack/vue-start-server@7776@tanstack/zod-adapter
npm i https://pkg.pr.new/@tanstack/zod-adapter@7776commit:
7404bb0Bundle Size Benchmarks#
- Commit:
814783c0428b - Measured at:
2026-10-24T18:47:12.058Z - Baseline source:
history:6b9fe6d29552 - Dashboard: bundle-size history
The following scenarios have bundle-size changes compared with the baseline:
Scenario Current (gzip) Initial (gzip) Raw Brotli Trend react-router.minimal84.5 KiB
+441 B84.3 KiB
+445 B262.6 KiB
+1.2 KiB73.8 KiB
+479 B▁▁▁▁▁▁▁▁▁▁▁█
react-router.full88.0 KiB
+440 B87.9 KiB
+442 B274.5 KiB
+1.2 KiB76.8 KiB
+402 B▁▁▁▁▁▁▁▁▁▁▁█
solid-router.minimal33.7 KiB
+408 B33.6 KiB
+408 B96.4 KiB
+1.2 KiB30.5 KiB
+385 B▁▁▁▁▁▁▁▁▁▁▁█
solid-router.full38.7 KiB
+424 B38.5 KiB
+424 B111.2 KiB
+1.2 KiB35.0 KiB
+490 B▁▁▁▁▁▁▁▁▁▁▁█
vue-router.minimal49.8 KiB
+435 B49.7 KiB
+437 B137.6 KiB
+1.2 KiB45.2 KiB
+401 B▁▁▁▁▁▁▁▁▁▁▁█
vue-router.full55.4 KiB
+454 B55.3 KiB
+452 B155.8 KiB
+1.2 KiB50.1 KiB
+401 B▁▁▁▁▁▁▁▁▁▁▁█
react-start.minimal97.2 KiB
+443 B97.1 KiB
+440 B303.5 KiB
+1.2 KiB84.5 KiB
+363 B▁▁▁▁▁▁▁▁▁▁▁█
react-start.query-integration104.6 KiB
+444 B104.5 KiB
+447 B330.1 KiB
+1.2 KiB90.8 KiB
+361 B▁▁▁▁▁▁▁▁▁▁▁█
react-start.deferred-hydration97.9 KiB
+468 B97.1 KiB
+466 B304.9 KiB
+1.2 KiB85.1 KiB
+430 B▁▁▁▁▁▁▁▁▁▁▁█
react-start.full100.3 KiB
+447 B100.2 KiB
+450 B312.8 KiB
+1.2 KiB87.1 KiB
+566 B▁▁▁▁▁▁▁▁▁▁▁█
react-start.rsbuild.minimal100.8 KiB
+456 B100.6 KiB
+456 B314.5 KiB
+1.2 KiB87.1 KiB
+462 B▁▁▁▁▁▁▁▁▁▁▁█
react-start.rsbuild.minimal-iife101.2 KiB
+456 B101.0 KiB
+456 B315.4 KiB
+1.2 KiB87.4 KiB
+443 B▁▁▁▁▁▁▁▁▁▁▁█
react-start.rsbuild.full104.0 KiB
+446 B103.8 KiB
+446 B324.2 KiB
+1.2 KiB89.7 KiB
+362 B▁▁▁▁▁▁▁▁▁▁▁█
solid-start.minimal46.6 KiB
+424 B46.4 KiB
+422 B136.2 KiB
+1.2 KiB41.5 KiB
+419 B▁▁▁▁▁▁▁▁▁▁▁█
solid-start.deferred-hydration49.6 KiB
+421 B46.5 KiB
+421 B143.5 KiB
+1.2 KiB44.4 KiB
+470 B▁▁▁▁▁▁▁▁▁▁▁█
solid-start.full51.6 KiB
+426 B51.5 KiB
+425 B151.2 KiB
+1.2 KiB45.8 KiB
+337 B▁▁▁▁▁▁▁▁▁▁▁█
vue-start.minimal65.8 KiB
+439 B65.7 KiB
+443 B186.9 KiB
+1.2 KiB58.8 KiB
+317 B▁▁▁▁▁▁▁▁▁▁▁█
vue-start.full69.6 KiB
+457 B69.4 KiB
+455 B198.7 KiB
+1.2 KiB62.0 KiB
+378 B▁▁▁▁▁▁▁▁▁▁▁█
Current gzip tracks all emitted client JS chunks. Initial gzip tracks only the entry/import graph. Trend sparkline is historical current gzip ending with this PR measurement; lower is better.
- Commit:
Merging this PR will degrade performance by 0.29%#
2 warnings
:warning: 38 benchmarks are dominated by system calls
System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.
:warning: Base and head ran on different runner types
Some benchmarks with significant performance changes were compared across different runner types, so the changes might not come from the code. Run base and head on the same runner type, or use CodSpeed Macro Runners for more stable results.
⚡ 6improved benchmarks❌ 6regressed benchmarks✅ 182untouched benchmarks⏩ 3skipped benchmarks1Warning
Please fix the performance issues or acknowledge them on CodSpeed.
Performance Changes#
Mode Benchmark BASEHEADEfficiency ❌ Memory mem client preload-churn (react)78.3 KB 84.9 KB -7.77% ❌ Memory mem server error-paths redirect (react)12.4 KB 13.4 KB -7.46% ❌ CPU Simulation ssr assets inline-css cdn (vue)360.6 ms 382.8 ms -5.79% ❌ CPU Simulation ssr assets inline-css cdn (solid)181.2 ms 190.6 ms -4.9% ❌ Memory mem client preload-churn (solid)75.5 KB 79.4 KB -4.85% ❌ Memory mem client navigation-churn (solid)107.4 KB 111.6 KB -3.79% ⚡ Memory mem client navigation-churn (react)83.6 KB 76 KB +10.07% ⚡ Memory mem client interrupted-navigations (react)94.7 KB 87.4 KB +8.41% ⚡ Memory mem server aborted-requests (react)298.5 KB 285.6 KB +4.51% ⚡ Memory mem server error-paths redirect (vue)13.1 KB 12.6 KB +3.61% ⚡ Memory mem client unique-location-churn (vue)82.9 KB 80 KB +3.59% ⚡ Memory mem client interrupted-navigations (vue)95.7 KB 92.9 KB +3.04% Tip
Investigate this regression by commenting
@codspeedbot fix this regressionon this PR, or directly use the CodSpeed MCP with your agent.
Comparingmatch-route-parsed-params(7404bb0) withmain(6b9fe6d)Footnotes#
-
3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
-
Important
At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.
Nx Cloud is proposing a fix for your failed CI:#
We extracted the anonymous
componentarrow function into a namedInvoiceComponentfunction to fix thereact-hooks/rules-of-hooksESLint error. The rule requires React component functions to start with an uppercase letter, which the lowercasecomponentproperty name did not satisfy. This change preserves the full test intent while making the hook usage compliant.Warning
❌ We could not verify this fix.
Suggested Fix changes
diff --git a/packages/react-router/tests/Matches.test.tsx b/packages/react-router/tests/Matches.test.tsx index e756a567..996c9d03 100644 --- a/packages/react-router/tests/Matches.test.tsx +++ b/packages/react-router/tests/Matches.test.tsx @@ -147,6 +147,16 @@ test('should show pendingComponent of root route', async () => { test('useMatchRoute matches typed params from routes with custom parse and stringify functions', async () => { const rootRoute = createRootRoute() + + function InvoiceComponent() { + const matchRoute = useMatchRoute() + const match = matchRoute({ + to: '/invoices/$invoiceId', + params: { invoiceId: 123 }, + }) + return <div data-testid="match">{JSON.stringify(match)}</div> + } + const invoiceRoute = createRoute({ getParentRoute: () => rootRoute, path: '/invoices/$invoiceId', @@ -158,15 +168,7 @@ test('useMatchRoute matches typed params from routes with custom parse and strin invoiceId: String(invoiceId), }), }, - component: () => { - const matchRoute = useMatchRoute() - const match = matchRoute({ - to: '/invoices/$invoiceId', - params: { invoiceId: 123 }, - }) - - return <div data-testid="match">{JSON.stringify(match)}</div> - }, + component: InvoiceComponent, }) const router = createRouter({ routeTree: rootRoute.addChildren([invoiceRoute]),🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.
Or Apply changes locally with:
Apply fix locally with your editor ↗ View interactive diff ↗npx nx-cloud apply-locally 9YYT-RTGB
🎓 Learn more about Self-Healing CI on [nx.dev](https://nx.dev/docs/features/ci-features/self-healing-ci?utm_source=pull-request&utm_medium=comment)I think it makes sense to fix this. But also
router.matchRouteis broken more generally because it does not take the route tree into account. It could returntruefor the specific route you're asking for, but when actually compared against the entire tree, another route would match because it had higher matching priority.@@ -2996,0 +2998,21 @@2998+ const destinationPath = trimPathRight(next.pathname)2999+ const destinationRoute = this.routesByPath[3000+ destinationPath as keyof typeof this.routesByPath3001+ ] as AnyRoute | undefined3002+ if (destinationRoute) {3003+ try {3004+ for (const matchedRoute of this.getRouteBranch(destinationRoute)) {3005+ const parseParams =3006+ matchedRoute.options.params?.parse ??3007+ matchedRoute.options.parseParams3008+ if (parseParams) {3009+ const parsedParams = parseParams(params as Record<string, string>)3010+ if (parsedParams === false) {3011+ return false3012+ }3013+ Object.assign(params, parsedParams)3014+ }3015+ }3016+ } catch {3017+ return false3018+ }I think this could be shortened using the
extractStrictParamsmethod that exists in this filefor (const matchedRoutes of this.getRouteBranch(destinationRoute)) { try { extractStrictParams(route, params) } catch { return false } }kk I updated to use it
LadyBluenotes(GitHub profile, opens in a new tab)replied on
packages/router-core/src/router.tslines 2757 to 2763kk I updated to use it
I think it makes sense to fix this. But also
router.matchRouteis broken more generally because it does not take the route tree into account. It could returntruefor the specific route you're asking for, but when actually compared against the entire tree, another route would match because it had higher matching priority.Added a regression for
osts/editversusposts/$postId. So when full-tree matching identifies/posts/editas the winner,matchRoute({ to: '/posts/$postId' })now returnsfalse. The existing fallback remains for route branches that cannot be resolved through parser-aware tree matching :))Important
At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.
Nx Cloud has identified a possible root cause for your failed CI:#
We determined that this failure is unrelated to the PR's changes, which are scoped entirely to router-core param parsing logic. The
tanstack-start-example-rscs:buildtask fails due to anitro/nitro-nightlypackage version incompatibility (ERR_PACKAGE_PATH_NOT_EXPORTED) in the environment. No fix is required on this PR.No code changes were suggested for this issue.
Trigger a rerun:
View detailed reasoning on Nx Cloud ↗
🎓 Learn more about Self-Healing CI on [nx.dev](https://nx.dev/docs/features/ci-features/self-healing-ci?utm_source=pull-request&utm_medium=comment)@Sheraff made the changes we talked about in discord
Actionable comments posted: 1
🧹 Nitpick comments (2)
packages/router-core/src/new-process-route-tree.ts (2)
812-849: 🚀 Performance & Scalability | 🔵 Trivial | ⚖️ Poor tradeofffindMatchalways redoes full extraction from scratch, discarding the incrementalextractstate already computed duringgetNodeMatch.When
includeRouteParamsis set, the constructedleafobject omitsextract(onlynode,skipped,rawParamsare carried over), forcingextractParamsto restart frompartIndex/nodeIndex/pathIndex/segmentCount = 0even though the winning frame may already have partially-resumedextractstate from earliervalidateParseParamscalls along the branch. This is correct but redundant for branches that use.parse(), doing O(n) extraction twice. Worth a look if this path is hot, though likely low priority given branch depth is typically small.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/router-core/src/new-process-route-tree.ts` around lines 812 - 849, Reuse the incremental extract state from getNodeMatch in findMatch instead of restarting extractParams from zero. Preserve the winning leaf frame’s extract data when constructing or passing the leaf, and update extractParams to continue from that state while retaining existing rawParams and matchData behavior.
688-696: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRouteMatchDatais defined but not reused for the identical inline shapes.The new
RouteMatchDatatype (line 858-862) exactly matches thematchDataelement shape that's independently inlined three more times:RouteMatch<T>.matchData(692-696),findMatch's return type (820-824), andextractParams's return tuple (885-889). Consolidating onto the shared alias avoids the four copies drifting apart if the shape changes later.♻️ Proposed refactor
type RouteMatch<T extends Extract<RouteLike, { fullPath: string }>> = { route: T rawParams: Record<string, string> branch: ReadonlyArray<T> - matchData: ReadonlyArray<{ - rawParams?: Record<string, string> - pathnameEnd: number - caseSensitive: boolean - }> + matchData: ReadonlyArray<RouteMatchData> }): { route: T rawParams: Record<string, string> - matchData?: ReadonlyArray<{ - rawParams?: Record<string, string> - pathnameEnd: number - caseSensitive: boolean - }> + matchData?: ReadonlyArray<RouteMatchData> } | null {extractedParams: Record<string, string>, - matchData?: Array<{ - rawParams?: Record<string, string> - pathnameEnd: number - caseSensitive: boolean - }>, + matchData?: Array<RouteMatchData>, ] {(Note: TypeScript type aliases aren't order-sensitive, so
RouteMatchDatacan be referenced ahead of its declaration without issue.)Also applies to: 813-825, 858-863, 885-889
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/router-core/src/new-process-route-tree.ts` around lines 688 - 696, Reuse the shared RouteMatchData alias for every matchData element type instead of repeating its inline shape. Update RouteMatch<T>.matchData, findMatch’s return type, and extractParams’ return tuple to reference RouteMatchData, while keeping the alias definition and existing type structure unchanged.🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. Inline comments: In `@packages/router-core/src/new-process-route-tree.ts`: - Line 951: Update the one-line conditionals in the route-tree logic: wrap the body of the `if (part)` statement around `pathIndex += part.length` and the body of the `if (result === false)` statement around `return null` in curly braces, preserving their existing behavior. --- Nitpick comments: In `@packages/router-core/src/new-process-route-tree.ts`: - Around line 812-849: Reuse the incremental extract state from getNodeMatch in findMatch instead of restarting extractParams from zero. Preserve the winning leaf frame’s extract data when constructing or passing the leaf, and update extractParams to continue from that state while retaining existing rawParams and matchData behavior. - Around line 688-696: Reuse the shared RouteMatchData alias for every matchData element type instead of repeating its inline shape. Update RouteMatch<T>.matchData, findMatch’s return type, and extractParams’ return tuple to reference RouteMatchData, while keeping the alias definition and existing type structure unchanged.🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID:
af4b87d9-0cd5-46e6-9821-c5369b926b71📥 Commits
Reviewing files that changed from the base of the PR and between 24a76d995b43ea64aab3aeb0be5666136599cd1a and 06a3de5c6172b99aa896816bd2004fbc40699cd8.
📒 Files selected for processing (7)
packages/router-core/src/new-process-route-tree.tspackages/router-core/src/router.tspackages/router-core/tests/match-by-path.test.tspackages/router-core/tests/match-route.test.tspackages/router-core/tests/optional-path-params-clean.test.tspackages/router-core/tests/optional-path-params.test.tspackages/router-core/tests/path.test.ts
💤 Files with no reviewable changes (1)
- packages/router-core/tests/match-by-path.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/router-core/src/router.ts
@@ -893,16 +932,20 @@893932 nodeIndex < list.length;894933 partIndex++, nodeIndex++, pathIndex++, segmentCount++895934 ) {896935 const node = list[nodeIndex]!897936 // index nodes are terminating nodes, nothing to extract, just leave898- if (node.kind === SEGMENT_TYPE_INDEX) break937+ if (node.kind === SEGMENT_TYPE_INDEX) {938+ recordRouteMatches(pathIndex)939+ break940+ }899941 // pathless nodes do not consume a path segment900942 if (node.kind === SEGMENT_TYPE_PATHLESS) {901943 segmentCount--902944 partIndex--903945 pathIndex--946+ recordRouteMatches(pathIndex)904947 continue905948 }906949 const part = parts[partIndex]907950 const currentPathIndex = pathIndex908951 if (part) pathIndex += part.length📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Curly braces required for
ifbodies.Two newly-added one-line
ifbodies violate the project's control-statement bracing rule:- Line 951:
if (part) pathIndex += part.length - Line 1441:
if (result === false) return null
As per coding guidelines: "Always use curly braces for if, else, loops, and similar control statements. Never write one-line bodies like
if (foo) x = 1."🔧 Proposed fix
- if (part) pathIndex += part.length + if (part) { + pathIndex += part.length + }const result = frame.node.parse(params as Record<string, string>) - if (result === false) return null + if (result === false) { + return null + }Also applies to: 1441-1441
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/router-core/src/new-process-route-tree.ts` at line 951, Update the one-line conditionals in the route-tree logic: wrap the body of the `if (part)` statement around `pathIndex += part.length` and the body of the `if (result === false)` statement around `return null` in curly braces, preserving their existing behavior.Source: Coding guidelines
✅ Addressed in commits df01347 to cbe3506
Important
At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.
Nx Cloud has identified a possible root cause for your failed CI:#
We identified that the
tanstack-start-example-rscs:buildfailure is caused by a pre-existing package incompatibility:nitro-nightlyimportsnitro/runtime/meta, a subpath not exported by the currently installednitroversion. This is unrelated to ourmatchRouteparameter-parsing fix, as no files in that example were touched by this PR.No code changes were suggested for this issue.
Trigger a rerun:
View detailed reasoning on Nx Cloud ↗
🎓 Learn more about Self-Healing CI on [nx.dev](https://nx.dev/docs/features/ci-features/self-healing-ci?utm_source=pull-request&utm_medium=comment)Important
At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.
Nx Cloud has identified a possible root cause for your failed CI:#
We classified this build failure as an environment issue rather than a code change. The failing project
tanstack-start-example-rscsis not touched by this PR, and the error (ERR_PACKAGE_PATH_NOT_EXPORTEDfornitro's./runtime/metasubpath) is a pre-existing dependency incompatibility betweennitro-nightlyand the installednitroversion. Our changes to route matching logic have no bearing on this failure.No code changes were suggested for this issue.
Trigger a rerun:
View detailed reasoning on Nx Cloud ↗
🎓 Learn more about Self-Healing CI on [nx.dev](https://nx.dev/docs/features/ci-features/self-healing-ci?utm_source=pull-request&utm_medium=comment)Can you remind me why we still need the
findSingleMatchmethod if it now respects the tree? Why not use the samefindRouteMatchas we use for regular route matching?does this collide with https://github.com/TanStack/router/pull/8327/changes?
does this collide with https://github.com/TanStack/router/pull/8327/changes?
there's conflicts in files, if that's what youre referring to. I can stack this on manuel's?
Important
At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.
Nx Cloud has identified a possible root cause for your failed CI:#
We believe this failure is unrelated to the PR changes. The error is a missing named export in a compiled dist artifact of
e2e-utils, which is not touched by this PR and points to a stale build in the CI environment. We recommend re-running the affected task to allow the environment to recover.No code changes were suggested for this issue.
Trigger a rerun:
View detailed reasoning on Nx Cloud ↗
🎓 Learn more about Self-Healing CI on [nx.dev](https://nx.dev/docs/features/ci-features/self-healing-ci?utm_source=pull-request&utm_medium=comment)Nx Cloud has identified a flaky task in your failed CI:#
🔂 Since the failure was identified as flaky, we triggered a CI rerun by adding an empty commit to this branch.
View detailed reasoning in Nx Cloud ↗
🎓 Learn more about Self-Healing CI on [nx.dev](https://nx.dev/docs/features/ci-features/self-healing-ci?utm_source=pull-request&utm_medium=comment)🦋 Changeset detected#
Latest commit: 7404bb0c95c904b7b268cb5236246b1e0bcb048e
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 23 packages
Name Type @tanstack/router-core Patch @tanstack/react-router Patch @tanstack/react-start-client Patch @tanstack/react-start-rsc Patch @tanstack/react-start-server Patch @tanstack/router-generator Patch @tanstack/router-plugin Patch @tanstack/solid-router Patch @tanstack/solid-start-client Patch @tanstack/solid-start-server Patch @tanstack/start-client-core Patch @tanstack/start-plugin-core Patch @tanstack/start-server-core Patch @tanstack/start-storage-context Patch @tanstack/vue-router Patch @tanstack/vue-start-client Patch @tanstack/vue-start-server Patch @tanstack/react-start Patch @tanstack/router-cli Patch @tanstack/router-vite-plugin Patch @tanstack/solid-start Patch @tanstack/start-static-server-functions Patch @tanstack/vue-start Patch Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
LadyBluenotes(GitHub profile, opens in a new tab) linked this to fix #2450
Sign in to join this conversation.
Note
Reviews paused#
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
reviews.auto_review.auto_pause_after_reviewed_commitssetting.Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.Use the checkboxes below for quick actions:
Walkthrough
matchRoutenow parses route parameters before matching and returns typed values. Route-tree extraction preserves parsed state across branches, core tests cover matching modes, and React, Solid, and Vue tests verify typed hook results.Changes: Typed route matching
packages/router-core/src/new-process-route-tree.tspackages/router-core/src/router.ts,.changeset/plenty-jokes-listen.mdmatchRouteresolves destination branches, validates parsed parameters and search values, handles fuzzy remainders, returns typed params, and updates processed-tree types.packages/router-core/tests/match-route.test.ts,packages/router-core/tests/{path,optional-path-params*}.test.tsfindRouteMatch.packages/{react-router,solid-router,vue-router}/tests/Matches.test.tsxuseMatchRoutereturns numeric parameters from custom parsers.Estimated code review effort: 4 (Complex) | ~60 minutes
Sequence Diagram(s)#
Possibly related PRs
matchRouteand route-tree matching around parsed parameter extraction and validation.Suggested labels:
package: router-coreSuggested reviewers:
schiller-manuel🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
#2450by making MatchRoute/matchRoute honor custom parse/stringify for numeric params and adding regression tests.✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share