Skip to content
Source
Sign inSign up
TanStack/router

fix(router-core): support parsed params in matchRoute #7776

OpenLadyBluenotes(GitHub profile, opens in a new tab)wants to merge 29 commits intomain frommatch-route-parsed-paramsopened

matchRoute now resolves matches through the processed route tree.

  • Applies route params.parse results 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 findSingleMatch and its cache with findRouteMatch.
  • 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.
    • matchRoute now returns parsed parameters (not raw strings) and correctly fails when typed parsing is rejected or throws.
    • Improved matching consistency across nested routes, including search and trailing-slash behavior.
  • Tests
    • Added/expanded matchRoute and useMatchRoute test coverage for React, Solid, and Vue, covering typed params, fuzzy matching, and mismatch cases.
  • Chores
    • Added a patch changeset documenting the matching fix.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: react-router

    2. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: router-core

    3. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: solid-router

    4. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: vue-router

    5. Review Change Stack

      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_commits setting.

      • Last reviewed commit: 06a3de5c6172b99aa896816bd2004fbc40699cd8
      • Latest commit, not reviewed: 7404bb0c95c904b7b268cb5236246b1e0bcb048e

      Use the following commands to manage reviews:

      • @coderabbitai resume to resume automatic reviews.
      • @coderabbitai review to trigger a single review.

      Use the checkboxes below for quick actions:

      • ▶️ Resume reviews
      • 🔍 Trigger review
      Walkthrough

      matchRoute now 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

      Layer / File(s)Summary
      Track parsed route parameters
      packages/router-core/src/new-process-route-tree.ts
      Route-tree matching records route metadata, separates raw and parsed parameters, and carries parsed values through parser validation and branch exploration.
      Parse parameters during route matching
      packages/router-core/src/router.ts, .changeset/plenty-jokes-listen.md
      matchRoute resolves destination branches, validates parsed parameters and search values, handles fuzzy remainders, returns typed params, and updates processed-tree types.
      Validate core matching behavior
      packages/router-core/tests/match-route.test.ts, packages/router-core/tests/{path,optional-path-params*}.test.ts
      Tests cover typed parsing, parser failures, parent-child params, fuzzy and case-sensitive matching, search, base paths, trailing slashes, and migration to findRouteMatch.
      Verify typed adapter results
      packages/{react-router,solid-router,vue-router}/tests/Matches.test.tsx
      Framework adapter tests verify that useMatchRoute returns numeric parameters from custom parsers.

      Estimated code review effort: 4 (Complex) | ~60 minutes

      Sequence Diagram(s)

      sequenceDiagram
        participant useMatchRoute
        participant RouterCoreMatchRoute
        participant RouteTreeMatcher
        participant RouteParamParser
        useMatchRoute->>RouterCoreMatchRoute: Match route with typed params
        RouterCoreMatchRoute->>RouteTreeMatcher: Resolve destination branch
        RouteTreeMatcher->>RouteParamParser: Parse extracted parameters
        RouteParamParser-->>RouteTreeMatcher: Return parsed params or rejection
        RouteTreeMatcher-->>RouterCoreMatchRoute: Return parsed route match
        RouterCoreMatchRoute-->>useMatchRoute: Return typed match or false

      Possibly related PRs

      • TanStack/router#5722: Updates matchRoute and route-tree matching around parsed parameter extraction and validation.

      Suggested labels: package: router-core

      Suggested reviewers: schiller-manuel

      🚥 Pre-merge checks | ✅ 4 | ❌ 1

      ❌ Failed checks (1 warning)

      Check nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring coverage is 40.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
      Title check✅ PassedThe title clearly summarizes the main change: matchRoute now supports parsed params.
      Linked Issues check✅ PassedThe changes address #2450 by making MatchRoute/matchRoute honor custom parse/stringify for numeric params and adding regression tests.
      Out of Scope Changes check✅ PassedThe deletions and API updates appear tied to the matchRoute refactor and related test coverage, with no unrelated changes evident.
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Commit unit tests in branch `match-route-parsed-params`
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      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
      Comment `@coderabbitai help` to get the list of available commands.
    6. View your CI Pipeline Execution ↗ for commit 7404bb0c95c904b7b268cb5236246b1e0bcb048e

      CommandStatusDurationResult
      nx run-many --target=build --exclude=examples/*...✅ Succeeded1m 47sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-10-24 18:52:13 UTC

    7. 🚀 Changeset Version Preview

      1 package(s) bumped directly, 22 bumped as dependents.

      🟩 Patch bumps

      PackageVersionReason
      @tanstack/router-core1.171.39 → 1.171.40Changeset
      @tanstack/react-router1.170.46 → 1.170.47Dependent
      @tanstack/react-start1.169.4 → 1.169.5Dependent
      @tanstack/react-start-client1.168.44 → 1.168.45Dependent
      @tanstack/react-start-rsc0.1.65 → 0.1.66Dependent
      @tanstack/react-start-server1.167.52 → 1.167.53Dependent
      @tanstack/router-cli1.167.46 → 1.167.47Dependent
      @tanstack/router-generator1.167.46 → 1.167.47Dependent
      @tanstack/router-plugin1.168.48 → 1.168.49Dependent
      @tanstack/router-vite-plugin1.167.48 → 1.167.49Dependent
      @tanstack/solid-router1.170.43 → 1.170.44Dependent
      @tanstack/solid-start1.169.4 → 1.169.5Dependent
      @tanstack/solid-start-client1.168.42 → 1.168.43Dependent
      @tanstack/solid-start-server1.167.50 → 1.167.51Dependent
      @tanstack/start-client-core1.170.39 → 1.170.40Dependent
      @tanstack/start-plugin-core1.171.55 → 1.171.56Dependent
      @tanstack/start-server-core1.169.45 → 1.169.46Dependent
      @tanstack/start-static-server-functions1.167.44 → 1.167.45Dependent
      @tanstack/start-storage-context1.167.41 → 1.167.42Dependent
      @tanstack/vue-router1.170.42 → 1.170.43Dependent
      @tanstack/vue-start1.169.4 → 1.169.5Dependent
      @tanstack/vue-start-client1.167.45 → 1.167.46Dependent
      @tanstack/vue-start-server1.167.50 → 1.167.51Dependent
    8. More templates

      @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@7776

      commit: 7404bb0

    9. Bundle 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:

      ScenarioCurrent (gzip)Initial (gzip)RawBrotliTrend
      react-router.minimal84.5 KiB
      +441 B
      84.3 KiB
      +445 B
      262.6 KiB
      +1.2 KiB
      73.8 KiB
      +479 B
      ▁▁▁▁▁▁▁▁▁▁▁█
      react-router.full88.0 KiB
      +440 B
      87.9 KiB
      +442 B
      274.5 KiB
      +1.2 KiB
      76.8 KiB
      +402 B
      ▁▁▁▁▁▁▁▁▁▁▁█
      solid-router.minimal33.7 KiB
      +408 B
      33.6 KiB
      +408 B
      96.4 KiB
      +1.2 KiB
      30.5 KiB
      +385 B
      ▁▁▁▁▁▁▁▁▁▁▁█
      solid-router.full38.7 KiB
      +424 B
      38.5 KiB
      +424 B
      111.2 KiB
      +1.2 KiB
      35.0 KiB
      +490 B
      ▁▁▁▁▁▁▁▁▁▁▁█
      vue-router.minimal49.8 KiB
      +435 B
      49.7 KiB
      +437 B
      137.6 KiB
      +1.2 KiB
      45.2 KiB
      +401 B
      ▁▁▁▁▁▁▁▁▁▁▁█
      vue-router.full55.4 KiB
      +454 B
      55.3 KiB
      +452 B
      155.8 KiB
      +1.2 KiB
      50.1 KiB
      +401 B
      ▁▁▁▁▁▁▁▁▁▁▁█
      react-start.minimal97.2 KiB
      +443 B
      97.1 KiB
      +440 B
      303.5 KiB
      +1.2 KiB
      84.5 KiB
      +363 B
      ▁▁▁▁▁▁▁▁▁▁▁█
      react-start.query-integration104.6 KiB
      +444 B
      104.5 KiB
      +447 B
      330.1 KiB
      +1.2 KiB
      90.8 KiB
      +361 B
      ▁▁▁▁▁▁▁▁▁▁▁█
      react-start.deferred-hydration97.9 KiB
      +468 B
      97.1 KiB
      +466 B
      304.9 KiB
      +1.2 KiB
      85.1 KiB
      +430 B
      ▁▁▁▁▁▁▁▁▁▁▁█
      react-start.full100.3 KiB
      +447 B
      100.2 KiB
      +450 B
      312.8 KiB
      +1.2 KiB
      87.1 KiB
      +566 B
      ▁▁▁▁▁▁▁▁▁▁▁█
      react-start.rsbuild.minimal100.8 KiB
      +456 B
      100.6 KiB
      +456 B
      314.5 KiB
      +1.2 KiB
      87.1 KiB
      +462 B
      ▁▁▁▁▁▁▁▁▁▁▁█
      react-start.rsbuild.minimal-iife101.2 KiB
      +456 B
      101.0 KiB
      +456 B
      315.4 KiB
      +1.2 KiB
      87.4 KiB
      +443 B
      ▁▁▁▁▁▁▁▁▁▁▁█
      react-start.rsbuild.full104.0 KiB
      +446 B
      103.8 KiB
      +446 B
      324.2 KiB
      +1.2 KiB
      89.7 KiB
      +362 B
      ▁▁▁▁▁▁▁▁▁▁▁█
      solid-start.minimal46.6 KiB
      +424 B
      46.4 KiB
      +422 B
      136.2 KiB
      +1.2 KiB
      41.5 KiB
      +419 B
      ▁▁▁▁▁▁▁▁▁▁▁█
      solid-start.deferred-hydration49.6 KiB
      +421 B
      46.5 KiB
      +421 B
      143.5 KiB
      +1.2 KiB
      44.4 KiB
      +470 B
      ▁▁▁▁▁▁▁▁▁▁▁█
      solid-start.full51.6 KiB
      +426 B
      51.5 KiB
      +425 B
      151.2 KiB
      +1.2 KiB
      45.8 KiB
      +337 B
      ▁▁▁▁▁▁▁▁▁▁▁█
      vue-start.minimal65.8 KiB
      +439 B
      65.7 KiB
      +443 B
      186.9 KiB
      +1.2 KiB
      58.8 KiB
      +317 B
      ▁▁▁▁▁▁▁▁▁▁▁█
      vue-start.full69.6 KiB
      +457 B
      69.4 KiB
      +455 B
      198.7 KiB
      +1.2 KiB
      62.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.

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

      Learn more about system calls

      See affected benchmarks

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

      Learn more about Macro Runners

      Open the report in CodSpeed to investigate

      ⚡ 6 improved benchmarks ❌ 6 regressed benchmarks ✅ 182 untouched benchmarks ⏩ 3 skipped benchmarks1

      Warning

      Please fix the performance issues or acknowledge them on CodSpeed.

      Performance Changes

      ModeBenchmarkBASEHEADEfficiency
      ❌Memorymem client preload-churn (react)78.3 KB84.9 KB-7.77%
      ❌Memorymem server error-paths redirect (react)12.4 KB13.4 KB-7.46%
      ❌CPU Simulationssr assets inline-css cdn (vue)360.6 ms382.8 ms-5.79%
      ❌CPU Simulationssr assets inline-css cdn (solid)181.2 ms190.6 ms-4.9%
      ❌Memorymem client preload-churn (solid)75.5 KB79.4 KB-4.85%
      ❌Memorymem client navigation-churn (solid)107.4 KB111.6 KB-3.79%
      ⚡Memorymem client navigation-churn (react)83.6 KB76 KB+10.07%
      ⚡Memorymem client interrupted-navigations (react)94.7 KB87.4 KB+8.41%
      ⚡Memorymem server aborted-requests (react)298.5 KB285.6 KB+4.51%
      ⚡Memorymem server error-paths redirect (vue)13.1 KB12.6 KB+3.61%
      ⚡Memorymem client unique-location-churn (vue)82.9 KB80 KB+3.59%
      ⚡Memorymem client interrupted-navigations (vue)95.7 KB92.9 KB+3.04%

      Tip

      Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


      Comparing match-route-parsed-params (7404bb0) with main (6b9fe6d) Open in CodSpeed

      Footnotes

      1. 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. ↩

    11. 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 component arrow function into a named InvoiceComponent function to fix the react-hooks/rules-of-hooks ESLint error. The rule requires React component functions to start with an uppercase letter, which the lowercase component property 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.

      Apply fix via Nx Cloud  Reject fix via Nx Cloud


      Or Apply changes locally with:

      npx nx-cloud apply-locally 9YYT-RTGB
      Apply fix locally with your editor ↗   View interactive diff ↗

      🎓 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)
    12. I think it makes sense to fix this. But also router.matchRoute is broken more generally because it does not take the route tree into account. It could return true for 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.

      OutdatedResolvedby LadyBluenotes(GitHub profile, opens in a new tab)
    13. LadyBluenotes(GitHub profile, opens in a new tab)replied on packages/router-core/src/router.ts lines 2757 to 2763

      kk I updated to use it

    14. I think it makes sense to fix this. But also router.matchRoute is broken more generally because it does not take the route tree into account. It could return true for 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/edit versus posts/$postId. So when full-tree matching identifies /posts/edit as the winner, matchRoute({ to: '/posts/$postId' }) now returns false. The existing fallback remains for route branches that cannot be resolved through parser-aware tree matching :))

    15. 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:build task fails due to a nitro/nitro-nightly package 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:

      Rerun CI

      Nx Cloud 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)
    16. @Sheraff made the changes we talked about in discord

    17. Actionable comments posted: 1

      🧹 Nitpick comments (2)
      packages/router-core/src/new-process-route-tree.ts (2)

      812-849: 🚀 Performance & Scalability | 🔵 Trivial | ⚖️ Poor tradeoff

      findMatch always redoes full extraction from scratch, discarding the incremental extract state already computed during getNodeMatch.

      When includeRouteParams is set, the constructed leaf object omits extract (only node, skipped, rawParams are carried over), forcing extractParams to restart from partIndex/nodeIndex/pathIndex/segmentCount = 0 even though the winning frame may already have partially-resumed extract state from earlier validateParseParams calls 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 win

      RouteMatchData is defined but not reused for the identical inline shapes.

      The new RouteMatchData type (line 858-862) exactly matches the matchData element shape that's independently inlined three more times: RouteMatch<T>.matchData (692-696), findMatch's return type (820-824), and extractParams'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 RouteMatchData can 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.ts
      • packages/router-core/src/router.ts
      • packages/router-core/tests/match-by-path.test.ts
      • packages/router-core/tests/match-route.test.ts
      • packages/router-core/tests/optional-path-params-clean.test.ts
      • packages/router-core/tests/optional-path-params.test.ts
      • packages/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
      OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)
    18. 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:build failure is caused by a pre-existing package incompatibility: nitro-nightly imports nitro/runtime/meta, a subpath not exported by the currently installed nitro version. This is unrelated to our matchRoute parameter-parsing fix, as no files in that example were touched by this PR.

      No code changes were suggested for this issue.

      Trigger a rerun:

      Rerun CI

      Nx Cloud 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)
    19. 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-rscs is not touched by this PR, and the error (ERR_PACKAGE_PATH_NOT_EXPORTED for nitro's ./runtime/meta subpath) is a pre-existing dependency incompatibility between nitro-nightly and the installed nitro version. Our changes to route matching logic have no bearing on this failure.

      No code changes were suggested for this issue.

      Trigger a rerun:

      Rerun CI

      Nx Cloud 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)
    20. Can you remind me why we still need the findSingleMatch method if it now respects the tree? Why not use the same findRouteMatch as we use for regular route matching?

    21. 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?

    22. 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:

      Rerun CI

      Nx Cloud 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)
    23. 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.

      Nx Cloud 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)
    24. 🦋 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
      NameType
      @tanstack/router-corePatch
      @tanstack/react-routerPatch
      @tanstack/react-start-clientPatch
      @tanstack/react-start-rscPatch
      @tanstack/react-start-serverPatch
      @tanstack/router-generatorPatch
      @tanstack/router-pluginPatch
      @tanstack/solid-routerPatch
      @tanstack/solid-start-clientPatch
      @tanstack/solid-start-serverPatch
      @tanstack/start-client-corePatch
      @tanstack/start-plugin-corePatch
      @tanstack/start-server-corePatch
      @tanstack/start-storage-contextPatch
      @tanstack/vue-routerPatch
      @tanstack/vue-start-clientPatch
      @tanstack/vue-start-serverPatch
      @tanstack/react-startPatch
      @tanstack/router-cliPatch
      @tanstack/router-vite-pluginPatch
      @tanstack/solid-startPatch
      @tanstack/start-static-server-functionsPatch
      @tanstack/vue-startPatch

      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

Sign in to join this conversation.