feat(route-modules): install route-module behavior with createRouteModuleRouter #8845
monorepo fromroute-modules-router-factory·opened 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),createModuleRootand 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
routeModulesbinding (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.initreads the module-root id while the router is created. For a module installed several times, template initialization inmountRouteModulesets the root template's<pkg>:id itself.Development checks.
createRouterthrows, with an error that namescreateRouteModuleRouter(), in two cases:- its route tree contains a mounted module;
buildLocationreceives options from a module's generated APIs.
Both checks are gated by
process.env.NODE_ENVand 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.tsbecameroute-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:eslintandtest:buildpass 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
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.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand. Run configuration-
- Source mode: Auto
- Repository: TanStack/router
- Branch: route-modules-router-factory
- File: .coderabbit.yaml
- Commit: 3325eb7
- Layers: Repository YAML
- Review profile: CHILL
- Plan: Advanced
- Run ID:
5a88c63d-2bcb-4a4d-bd86-457cb54494b7
You can disable this status message by setting the
reviews.review_statustofalsein 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.
-
Codex Review Summary#
This comment shows the latest Codex review activity on this pull request.
Review Status Commit Review trigger 🔒 Security Review ✅ Completed 2026-11-02T17:55:24.278949Z 3325eb7PR 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.
github-actions[bot](GitHub profile, opens in a new tab) added labelsdocumentation
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: router-generator
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: react-start
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: router-devtools-core
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: solid-start
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-plugin-core
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: vue-router
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: vue-start
View your CI Pipeline Execution ↗ for commit 3325eb74517c2af08c2b12b556d7b07c9704ccc3
Command Status Duration Result nx affected --targets=test:eslint,test:unit,tes...❌ Failed 10m 10s View ↗ nx run-many --target=build --exclude=examples/*...✅ Succeeded 1m 55s View ↗
☁️ Nx Cloud last updated this comment at
2026-11-02 18:08:08UTC🚀 Changeset Version Preview#
16 package(s) bumped directly, 13 bumped as dependents.
🟨 Minor bumps#
Package Version Reason @tanstack/eslint-plugin-router1.162.0 → 1.163.0 Changeset @tanstack/react-router1.170.46 → 1.171.0 Changeset @tanstack/react-start1.169.4 → 1.170.0 Changeset @tanstack/react-start-rsc0.1.65 → 0.2.0 Changeset @tanstack/router-cli1.167.46 → 1.168.0 Changeset @tanstack/router-core1.171.39 → 1.172.0 Changeset @tanstack/router-devtools-core1.168.2 → 1.169.0 Changeset @tanstack/router-generator1.167.46 → 1.168.0 Changeset @tanstack/router-plugin1.168.48 → 1.169.0 Changeset @tanstack/router-vite-plugin1.167.48 → 1.168.0 Changeset @tanstack/solid-router1.170.43 → 1.171.0 Changeset @tanstack/solid-start1.169.4 → 1.170.0 Changeset @tanstack/start-client-core1.170.39 → 1.171.0 Changeset @tanstack/start-plugin-core1.171.55 → 1.172.0 Changeset @tanstack/vue-router1.170.42 → 1.171.0 Changeset @tanstack/vue-start1.169.4 → 1.170.0 Changeset 🟩 Patch bumps#
Package Version Reason @tanstack/react-router-devtools1.167.2 → 1.167.3 Dependent @tanstack/react-start-client1.168.44 → 1.168.45 Dependent @tanstack/react-start-server1.167.52 → 1.167.53 Dependent @tanstack/router-devtools1.167.2 → 1.167.3 Dependent @tanstack/solid-router-devtools1.167.2 → 1.167.3 Dependent @tanstack/solid-start-client1.168.42 → 1.168.43 Dependent @tanstack/solid-start-server1.167.50 → 1.167.51 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-router-devtools1.167.2 → 1.167.3 Dependent @tanstack/vue-start-client1.167.45 → 1.167.46 Dependent @tanstack/vue-start-server1.167.50 → 1.167.51 Dependent 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:
Scenario Current (gzip) Initial (gzip) Raw Brotli Trend react-router.route-modules87.0 KiB
n/a86.6 KiB
n/a266.0 KiB
n/a76.5 KiB
n/a▅
solid-router.full38.3 KiB
+4 B38.1 KiB
+4 B110.0 KiB
+6 B34.5 KiB
-28 B▁▁▁▁▁▁▁▁▁▁▁█
vue-router.minimal49.4 KiB
-15 B49.3 KiB
-14 B136.4 KiB
-34 B44.8 KiB
-22 B███████████▁
vue-router.full55.0 KiB
+29 B54.9 KiB
+29 B154.7 KiB
+98 B49.7 KiB
+28 B▁▁▁▁▁▁▁▁▁▁▁█
react-start.route-modules99.7 KiB
n/a99.3 KiB
n/a307.0 KiB
n/a87.5 KiB
n/a▅
react-start.rsbuild.minimal100.6 KiB
+269 B100.4 KiB
+268 B313.9 KiB
+714 B86.9 KiB
+257 B▁▁▁▁▁▁▁▁▁▁▁█
react-start.rsbuild.minimal-iife101.0 KiB
+271 B100.9 KiB
+271 B314.9 KiB
+714 B87.3 KiB
+308 B▁▁▁▁▁▁▁▁▁▁▁█
react-start.rsbuild.full103.8 KiB
+290 B103.6 KiB
+289 B323.6 KiB
+712 B89.5 KiB
+157 B▁▁▁▁▁▁▁▁▁▁▁█
solid-start.full51.2 KiB
+11 B51.1 KiB
+7 B150.0 KiB
+4 B45.4 KiB
-42 B▁▁▁▁▁▁▁▁▁▁▁█
vue-start.minimal65.4 KiB
-13 B65.2 KiB
-12 B185.7 KiB
-38 B58.5 KiB
+29 B███████████▁
vue-start.full69.2 KiB
+45 B69.0 KiB
+44 B197.6 KiB
+97 B61.7 KiB
+53 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:
More templates
- 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-large-route-modules
- 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-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/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@8845commit:
3325eb7Merging 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.
: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.
⚡ 1improved benchmark❌ 2regressed benchmarks✅ 191untouched benchmarks⏩ 3skipped benchmarks1Warning
Please fix the performance issues or acknowledge them on CodSpeed.
Performance Changes#
Mode Benchmark BASEHEADEfficiency ❌ Memory mem client navigation-churn (solid)108.6 KB 114.9 KB -5.52% ❌ Memory mem server error-paths redirect (vue)12.6 KB 13.1 KB -3.48% ⚡ Memory mem server error-paths redirect (react)12.4 KB 12 KB +3.25% Tip
Investigate this regression by commenting
@codspeedbot fix this regressionon this PR, or directly use the CodSpeed MCP with your agent.
Comparingroute-modules-router-factory(3325eb7) withmonorepo(5a87486)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. ↩
-
Sign in to join this conversation.
⚠️ 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
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