Skip to content
Source
Sign inSign up
TanStack/router

feat(route-modules): install route-module behavior with createRouteModuleRouter #8845

Openschiller-manuel(GitHub profile, opens in a new tab)wants to merge 1 commit intomonorepo fromroute-modules-router-factoryopened

Stacked on #8842.

Applications that mount route modules now create their router with createRouteModuleRouter. It is a named export of @tanstack/react-router, @tanstack/solid-router and @tanstack/vue-router, and it takes the same options and returns the same router as createRouter. It is the one place that installs the route-module behavior, before the router is created. Applications without route modules keep createRouter and ship none of that code.

import { createRouteModuleRouter } from '@tanstack/react-router'
import { routeTree } from './routeTree.gen'

export const router = createRouteModuleRouter({ routeTree })

A TanStack Start application returns it from getRouter().

Changes

  • One install site. Before this change, module code installed the behavior when it ran: mountRouteModule, bindRouteScopeOptions (on every call), createModuleRoot and the Link binders. The binders did so inside calls marked /* @__PURE__ */. Now only the factory installs it.

  • One core binding. The core holds the behavior in a single never-assigned routeModules binding (route-module-hooks.ts) instead of four hook variables. It holds the module-root id, id resolution, location scoping and the navigation scope of route-bound APIs.

  • Nothing reads the behavior at import. Route.init reads the module-root id while the router is created. For a module installed several times, template initialization in mountRouteModule sets the root template's <pkg>: id itself.

  • Development checks. createRouter throws, with an error that names createRouteModuleRouter(), in two cases:

    • its route tree contains a mounted module;
    • buildLocation receives options from a module's generated APIs.

    Both checks are gated by process.env.NODE_ENV and are absent from production builds.

  • Hosts and docs. The route-modules e2e apps, the large Start example and the bundle-size scenarios use the factory. The router and Start route-modules guides document it, and the router changeset mentions it.

  • Tests. route-module-unmounted.test.ts became route-module-router.test.ts. It covers both development checks and the template ids set during import. The test of the removed production invariant is deleted.

Bundle size

Measured against the head of #8842 (5a87486046), full benchmark:

ScenarioΔ gzip
Every Vite scenario without route modules (React, Solid and Vue Router and Start, minimal and full)0 B
react-router.route-modules+34 B (the factory and the behavior object)
react-start.route-modules-6 B
react-start.rsbuild.minimal / minimal-iife / full+23 / +18 / +31 B

Rsbuild keeps the reads on the binding, and their member names are not minified. Whether to accept that cost or return to separate bindings is still open.

Validation

  • test:unit, test:types, test:eslint and test:build pass for router-core, the three framework routers, router-devtools-core, router-generator, start-plugin-core and the three Start packages.
  • The route-modules e2e suites pass for React, Solid and Vue Router and for React Start.
  • In the first full React Start run, the Vite dev HMR test "provider classification changes…" failed once. It passed 3/3 on its own and in a second full run.

🤖 Generated with Claude Code

    1. ⚠️ No Changeset found

      Latest commit: 3325eb74517c2af08c2b12b556d7b07c9704ccc3

      Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

      This PR includes changesets to release 23 packages
      NameType
      @tanstack/router-coreMinor
      @tanstack/react-routerMinor
      @tanstack/solid-routerMinor
      @tanstack/vue-routerMinor
      @tanstack/react-start-clientPatch
      @tanstack/react-start-rscPatch
      @tanstack/react-start-serverPatch
      @tanstack/router-generatorPatch
      @tanstack/router-pluginPatch
      @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-start-clientPatch
      @tanstack/vue-start-serverPatch
      @tanstack/react-startPatch
      @tanstack/solid-startPatch
      @tanstack/vue-startPatch
      @tanstack/router-cliPatch
      @tanstack/router-vite-pluginPatch
      @tanstack/start-static-server-functionsPatch

      Click here to learn what changesets are, and how to add one.

      Click here if you're a maintainer who wants to add a changeset to this PR

    2. Important

      Review skipped

      Auto reviews are disabled on base/target branches other than the default branch.

      Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      Run configuration

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • Trigger review
      • 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
    3. chatgpt-codex-connector[bot](GitHub profile, opens in a new tab)commented

      Codex Review Summary

      This comment shows the latest Codex review activity on this pull request.

      ReviewStatusCommitReview trigger
      🔒 Security Review✅ Completed 2026-11-02T17:55:24.278949Z3325eb7PR opened
      ℹ️ About Codex in GitHub

      Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

      • Open a pull request for review
      • Mark a draft as ready
      • Comment "@codex review" or "@codex security review".

      Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

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

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

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

    8. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: react-start

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

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

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

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

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

    14. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit 3325eb74517c2af08c2b12b556d7b07c9704ccc3

      CommandStatusDurationResult
      nx affected --targets=test:eslint,test:unit,tes...❌ Failed10m 10sView ↗
      nx run-many --target=build --exclude=examples/*...✅ Succeeded1m 55sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-11-02 18:08:08 UTC

    15. 🚀 Changeset Version Preview

      16 package(s) bumped directly, 13 bumped as dependents.

      🟨 Minor bumps

      PackageVersionReason
      @tanstack/eslint-plugin-router1.162.0 → 1.163.0Changeset
      @tanstack/react-router1.170.46 → 1.171.0Changeset
      @tanstack/react-start1.169.4 → 1.170.0Changeset
      @tanstack/react-start-rsc0.1.65 → 0.2.0Changeset
      @tanstack/router-cli1.167.46 → 1.168.0Changeset
      @tanstack/router-core1.171.39 → 1.172.0Changeset
      @tanstack/router-devtools-core1.168.2 → 1.169.0Changeset
      @tanstack/router-generator1.167.46 → 1.168.0Changeset
      @tanstack/router-plugin1.168.48 → 1.169.0Changeset
      @tanstack/router-vite-plugin1.167.48 → 1.168.0Changeset
      @tanstack/solid-router1.170.43 → 1.171.0Changeset
      @tanstack/solid-start1.169.4 → 1.170.0Changeset
      @tanstack/start-client-core1.170.39 → 1.171.0Changeset
      @tanstack/start-plugin-core1.171.55 → 1.172.0Changeset
      @tanstack/vue-router1.170.42 → 1.171.0Changeset
      @tanstack/vue-start1.169.4 → 1.170.0Changeset

      🟩 Patch bumps

      PackageVersionReason
      @tanstack/react-router-devtools1.167.2 → 1.167.3Dependent
      @tanstack/react-start-client1.168.44 → 1.168.45Dependent
      @tanstack/react-start-server1.167.52 → 1.167.53Dependent
      @tanstack/router-devtools1.167.2 → 1.167.3Dependent
      @tanstack/solid-router-devtools1.167.2 → 1.167.3Dependent
      @tanstack/solid-start-client1.168.42 → 1.168.43Dependent
      @tanstack/solid-start-server1.167.50 → 1.167.51Dependent
      @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-router-devtools1.167.2 → 1.167.3Dependent
      @tanstack/vue-start-client1.167.45 → 1.167.46Dependent
      @tanstack/vue-start-server1.167.50 → 1.167.51Dependent
    16. Bundle Size Benchmarks

      • Commit: b6eba91ea314
      • Measured at: 2026-11-02T17:56:43.465Z
      • Baseline source: history:f723f3b8be06
      • Dashboard: bundle-size history

      The following scenarios have bundle-size changes or lack baseline data for comparison:

      ScenarioCurrent (gzip)Initial (gzip)RawBrotliTrend
      react-router.route-modules87.0&nbsp;KiB
      n/a
      86.6&nbsp;KiB
      n/a
      266.0&nbsp;KiB
      n/a
      76.5&nbsp;KiB
      n/a
      ▅
      solid-router.full38.3&nbsp;KiB
      +4&nbsp;B
      38.1&nbsp;KiB
      +4&nbsp;B
      110.0&nbsp;KiB
      +6&nbsp;B
      34.5&nbsp;KiB
      -28&nbsp;B
      ▁▁▁▁▁▁▁▁▁▁▁█
      vue-router.minimal49.4&nbsp;KiB
      -15&nbsp;B
      49.3&nbsp;KiB
      -14&nbsp;B
      136.4&nbsp;KiB
      -34&nbsp;B
      44.8&nbsp;KiB
      -22&nbsp;B
      ███████████▁
      vue-router.full55.0&nbsp;KiB
      +29&nbsp;B
      54.9&nbsp;KiB
      +29&nbsp;B
      154.7&nbsp;KiB
      +98&nbsp;B
      49.7&nbsp;KiB
      +28&nbsp;B
      ▁▁▁▁▁▁▁▁▁▁▁█
      react-start.route-modules99.7&nbsp;KiB
      n/a
      99.3&nbsp;KiB
      n/a
      307.0&nbsp;KiB
      n/a
      87.5&nbsp;KiB
      n/a
      ▅
      react-start.rsbuild.minimal100.6&nbsp;KiB
      +269&nbsp;B
      100.4&nbsp;KiB
      +268&nbsp;B
      313.9&nbsp;KiB
      +714&nbsp;B
      86.9&nbsp;KiB
      +257&nbsp;B
      ▁▁▁▁▁▁▁▁▁▁▁█
      react-start.rsbuild.minimal-iife101.0&nbsp;KiB
      +271&nbsp;B
      100.9&nbsp;KiB
      +271&nbsp;B
      314.9&nbsp;KiB
      +714&nbsp;B
      87.3&nbsp;KiB
      +308&nbsp;B
      ▁▁▁▁▁▁▁▁▁▁▁█
      react-start.rsbuild.full103.8&nbsp;KiB
      +290&nbsp;B
      103.6&nbsp;KiB
      +289&nbsp;B
      323.6&nbsp;KiB
      +712&nbsp;B
      89.5&nbsp;KiB
      +157&nbsp;B
      ▁▁▁▁▁▁▁▁▁▁▁█
      solid-start.full51.2&nbsp;KiB
      +11&nbsp;B
      51.1&nbsp;KiB
      +7&nbsp;B
      150.0&nbsp;KiB
      +4&nbsp;B
      45.4&nbsp;KiB
      -42&nbsp;B
      ▁▁▁▁▁▁▁▁▁▁▁█
      vue-start.minimal65.4&nbsp;KiB
      -13&nbsp;B
      65.2&nbsp;KiB
      -12&nbsp;B
      185.7&nbsp;KiB
      -38&nbsp;B
      58.5&nbsp;KiB
      +29&nbsp;B
      ███████████▁
      vue-start.full69.2&nbsp;KiB
      +45&nbsp;B
      69.0&nbsp;KiB
      +44&nbsp;B
      197.6&nbsp;KiB
      +97&nbsp;B
      61.7&nbsp;KiB
      +53&nbsp;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.

    17. More templates

      @tanstack/arktype-adapter

      npm i https://pkg.pr.new/@tanstack/arktype-adapter@8845

      @tanstack/eslint-plugin-router

      npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@8845

      @tanstack/eslint-plugin-start

      npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@8845

      @tanstack/history

      npm i https://pkg.pr.new/@tanstack/history@8845

      @tanstack/react-router

      npm i https://pkg.pr.new/@tanstack/react-router@8845

      @tanstack/react-router-devtools

      npm i https://pkg.pr.new/@tanstack/react-router-devtools@8845

      @tanstack/react-router-ssr-query

      npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@8845

      @tanstack/react-start

      npm i https://pkg.pr.new/@tanstack/react-start@8845

      @tanstack/react-start-client

      npm i https://pkg.pr.new/@tanstack/react-start-client@8845

      @tanstack/react-start-rsc

      npm i https://pkg.pr.new/@tanstack/react-start-rsc@8845

      @tanstack/react-start-server

      npm i https://pkg.pr.new/@tanstack/react-start-server@8845

      @tanstack/router-cli

      npm i https://pkg.pr.new/@tanstack/router-cli@8845

      @tanstack/router-core

      npm i https://pkg.pr.new/@tanstack/router-core@8845

      @tanstack/router-devtools

      npm i https://pkg.pr.new/@tanstack/router-devtools@8845

      @tanstack/router-devtools-core

      npm i https://pkg.pr.new/@tanstack/router-devtools-core@8845

      @tanstack/router-generator

      npm i https://pkg.pr.new/@tanstack/router-generator@8845

      @tanstack/router-plugin

      npm i https://pkg.pr.new/@tanstack/router-plugin@8845

      @tanstack/router-ssr-query-core

      npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@8845

      @tanstack/router-utils

      npm i https://pkg.pr.new/@tanstack/router-utils@8845

      @tanstack/router-vite-plugin

      npm i https://pkg.pr.new/@tanstack/router-vite-plugin@8845

      @tanstack/solid-router

      npm i https://pkg.pr.new/@tanstack/solid-router@8845

      @tanstack/solid-router-devtools

      npm i https://pkg.pr.new/@tanstack/solid-router-devtools@8845

      @tanstack/solid-router-ssr-query

      npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@8845

      @tanstack/solid-start

      npm i https://pkg.pr.new/@tanstack/solid-start@8845

      @tanstack/solid-start-client

      npm i https://pkg.pr.new/@tanstack/solid-start-client@8845

      @tanstack/solid-start-server

      npm i https://pkg.pr.new/@tanstack/solid-start-server@8845

      @tanstack/start-client-core

      npm i https://pkg.pr.new/@tanstack/start-client-core@8845

      @tanstack/start-fn-stubs

      npm i https://pkg.pr.new/@tanstack/start-fn-stubs@8845

      @tanstack/start-plugin-core

      npm i https://pkg.pr.new/@tanstack/start-plugin-core@8845

      @tanstack/start-server-core

      npm i https://pkg.pr.new/@tanstack/start-server-core@8845

      @tanstack/start-static-server-functions

      npm i https://pkg.pr.new/@tanstack/start-static-server-functions@8845

      @tanstack/start-storage-context

      npm i https://pkg.pr.new/@tanstack/start-storage-context@8845

      @tanstack/valibot-adapter

      npm i https://pkg.pr.new/@tanstack/valibot-adapter@8845

      @tanstack/virtual-file-routes

      npm i https://pkg.pr.new/@tanstack/virtual-file-routes@8845

      @tanstack/vue-router

      npm i https://pkg.pr.new/@tanstack/vue-router@8845

      @tanstack/vue-router-devtools

      npm i https://pkg.pr.new/@tanstack/vue-router-devtools@8845

      @tanstack/vue-router-ssr-query

      npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@8845

      @tanstack/vue-start

      npm i https://pkg.pr.new/@tanstack/vue-start@8845

      @tanstack/vue-start-client

      npm i https://pkg.pr.new/@tanstack/vue-start-client@8845

      @tanstack/vue-start-server

      npm i https://pkg.pr.new/@tanstack/vue-start-server@8845

      @tanstack/zod-adapter

      npm i https://pkg.pr.new/@tanstack/zod-adapter@8845

      commit: 3325eb7

    18. Merging this PR will degrade performance by 1.99%

      2 warnings

      :warning: 49 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: 3 benchmarks with a significant change ran on different hardware

      Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

      Learn more about Macro Runners

      See affected benchmarks

      ⚡ 1 improved benchmark ❌ 2 regressed benchmarks ✅ 191 untouched benchmarks ⏩ 3 skipped benchmarks1

      Warning

      Please fix the performance issues or acknowledge them on CodSpeed.

      Performance Changes

      ModeBenchmarkBASEHEADEfficiency
      ❌Memorymem client navigation-churn (solid)108.6 KB114.9 KB-5.52%
      ❌Memorymem server error-paths redirect (vue)12.6 KB13.1 KB-3.48%
      ⚡Memorymem server error-paths redirect (react)12.4 KB12 KB+3.25%

      Tip

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


      Comparing route-modules-router-factory (3325eb7) with monorepo (5a87486) 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. ↩

Sign in to join this conversation.