Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
762f949
feat: experimental route modules for file-based routing
schiller-manuel Nov 1, 2026
2cb70db
test(route-modules): tidy the settings profile fixture pages
schiller-manuel Nov 1, 2026
d4ff4c7
fix(e2e): serve the Start route-modules dev app from one Vite copy
schiller-manuel Nov 1, 2026
aaa64fc
fix(route-modules): keep HMR updates and Windows lookups for mounted …
schiller-manuel Nov 2, 2026
efa5e51
test(route-modules): run Start build tests downstream and fix CI setup
schiller-manuel Nov 2, 2026
e365d5e
fix(ci): unify Vite's sass peer instead of deduping the lockfile
schiller-manuel Nov 2, 2026
3406eb1
perf(route-modules): ship route-module behavior only with route modules
schiller-manuel Nov 2, 2026
cdf03e1
test(bundle-size): measure apps with a mounted route module
schiller-manuel Nov 2, 2026
2269acc
feat(router-generator): configurable route-module namespace files
schiller-manuel Nov 2, 2026
195f218
perf(route-modules): no Link or useNavigate cost without route modules
schiller-manuel Nov 2, 2026
c460e6e
chore(changeset): mention the namespace file layout option
schiller-manuel Nov 2, 2026
f15819f
test(router-generator): read generated files by their absolute path
schiller-manuel Nov 2, 2026
b6b0d0a
fix(router-generator): name the namespace file callback type
schiller-manuel Nov 2, 2026
ec679c1
feat(router-generator): link route modules in both directions
schiller-manuel Nov 7, 2026
3767ebe
feat(eslint-plugin-router): report imports from used route modules
schiller-manuel Nov 7, 2026
a7e7465
fix(router-devtools-core): list module routes without the module root
schiller-manuel Nov 7, 2026
461688c
test(route-modules): cover linking in both directions in the react-ro…
schiller-manuel Nov 7, 2026
90c28e6
docs(route-modules): document linking in both directions
schiller-manuel Nov 7, 2026
ef219d3
refactor(route-modules): one core binding for the route-module behavior
schiller-manuel Nov 7, 2026
5cdbf90
fix(router-core): reject mounting a module root with and without a name
schiller-manuel Nov 7, 2026
0caab44
fix(router-core): build a location's mask in the scope of its destina…
schiller-manuel Nov 7, 2026
c0368e1
perf(router-core): resolve a not-found target once on the client
schiller-manuel Nov 7, 2026
6e20efc
fix(router-core): name a single named installation in its diagnostic
schiller-manuel Nov 7, 2026
b7489bb
perf(router-core): keep options already bound to their scope
schiller-manuel Nov 7, 2026
a048cf5
fix(router-plugin): compile module roots like root routes
schiller-manuel Nov 7, 2026
e296bde
fix(router-plugin): prefer the generated route id in webpack HMR stat…
schiller-manuel Nov 7, 2026
06e04a7
refactor(router-plugin): one watcher setup for webpack and Rspack
schiller-manuel Nov 7, 2026
96370df
perf(start-plugin-core): resolve client views only with mounted modules
schiller-manuel Nov 7, 2026
f1db26a
refactor(start-plugin-core): share the server-only route predicate
schiller-manuel Nov 7, 2026
1f68655
fix(router-core): type the module id of the installation diagnostic
schiller-manuel Nov 7, 2026
a49e5e5
fix(solid-router): keep each prop of a scoped component reactive
schiller-manuel Nov 7, 2026
924b3ff
refactor(route-modules): bind id-based scope APIs through one core he…
schiller-manuel Nov 7, 2026
fee0cd3
fix(vue-router): accept object scopes on MatchRoute
schiller-manuel Nov 7, 2026
dc72efd
fix(start-client-core): an any or never field cannot certify a requir…
schiller-manuel Nov 7, 2026
e913583
perf(start-client-core): skip module validation without module requir…
schiller-manuel Nov 7, 2026
f923c4f
test(start): define the route-module build test once for the three fr…
schiller-manuel Nov 7, 2026
19b50ad
perf(router-core): read module scopes only behind the route-module bi…
schiller-manuel Nov 7, 2026
cdf5f58
test(route-modules): sharpen the fixture assertions
schiller-manuel Nov 7, 2026
efac4fd
test(start): compile the team module's declarations against the stand…
schiller-manuel Nov 7, 2026
ac7eee1
chore(route-modules): include the stand-ins in the example and benchm…
schiller-manuel Nov 7, 2026
e086b4e
chore(e2e): declare vite for the route-modules fixture tests
schiller-manuel Nov 7, 2026
ff04889
docs(route-modules): state the mask rule and the Start validation limits
schiller-manuel Nov 7, 2026
ad7651b
chore(pnpm): regenerate the lockfile after rebasing on main
schiller-manuel Nov 11, 2026
250fbbd
ci: apply automated fixes
autofix-ci[bot] Nov 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 12 additions & 0 deletions .changeset/clever-buttons-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@tanstack/router-cli': minor
'@tanstack/router-plugin': minor
'@tanstack/router-vite-plugin': minor
'@tanstack/start-plugin-core': minor
'@tanstack/react-start': minor
'@tanstack/solid-start': minor
'@tanstack/vue-start': minor
'@tanstack/react-start-rsc': minor
---

Require Node.js 22.22.0 or later for Router and Start build tooling. Upgrade file watching to Chokidar 6.
5 changes: 5 additions & 0 deletions .changeset/itchy-chairs-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/router-plugin': patch
---

Preserve JSX and TypeScript syntax when splitting route components wrapped in calls such as React `memo` and Vue `defineComponent`.
5 changes: 5 additions & 0 deletions .changeset/route-modules-devtools.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/router-devtools-core': minor
---

Experimental: The router devtools show route modules. Each mounted module's routes form a collapsible group, nested where the module is mounted, and a filter narrows the route tree to one module. A module panel shows the module's mount path, parent module, routes with their module-local and final paths, and active matches. Matches carry a module badge, and match details show the module, the local path and the final path.
5 changes: 5 additions & 0 deletions .changeset/route-modules-eslint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/eslint-plugin-router': minor
---

Experimental: Add the `route-module-imports` rule, enabled in the recommended configs: files of a route module must import routing and Start APIs from the module's generated route scope, and must not import, in values or in types, from a module the package lists in `uses`. The rule only applies to packages that declare `tanstack.router.module`.
7 changes: 7 additions & 0 deletions .changeset/route-modules-generator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@tanstack/router-generator': minor
'@tanstack/router-cli': minor
'@tanstack/router-plugin': minor
---

Experimental: Generate route modules. A package that declares `tanstack.router.module` in its `package.json` gets qualified route ids (`<package>:<path>`), a generated route scope (`routeScope.gen.ts`, with one namespace file per included or used module, placed by the `routeScopeNamespaceFiles` option: `'indexed'`, `'named'`, `'folder'` or a function), a public contract (`routeContract.gen.ts`, exported as `./route-types` after the package's own declaration build), a runtime entry (`routeModule.gen.ts`, exported as `./route-module`) and a topology manifest (`.tanstack/route-module.json`) for includers. Module identity is the package name. Applications and modules mount modules with the `routeModules` option: `includes` chooses the host route and mount path of each module and `uses` references modules mounted elsewhere. An application installs a module several times by including it once per installation, each named with `as`; every installation gets its own namespace and route ids, and a module that uses it links to the installation mounted above it. A module mounted under path params gets a namespace typed with them in its includers; the generator rejects a module that uses it without being mounted below those params, and rejects mounts whose full paths collide. `tsr generate` emits the module files. Packages emit and check declarations with their own TypeScript projects; Nx or similar workspace tooling reruns generation and compilation in dependency order when sources, configuration or provider artifacts change. `tsr watch` retains its standalone route-directory and configuration watching. The bundler plugin compiles, code-splits and hot-updates mounted module routes, including every installation of a module installed several times. Route modules can use each other in both directions, and a module can use the module that includes it: `uses` is a contract relation, so generation reads only the used package's `package.json`, and the declaration build compiles against generated stand-ins for the used contracts (`.tanstack/route-types-stubs.d.ts`, to be included by the package's declaration build only); only the source check reads the real contracts. A used module may be declared in `dependencies`, `devDependencies` or `peerDependencies`. A module's contract (`routeContract.gen.ts`, which now declares the module's register and router types) reaches its own files, the framework and the contracts of included modules only; the routes of used modules are addressed through their namespaces. `includes` cycles are rejected with a diagnostic. Applications without route modules generate the same output as before.
8 changes: 8 additions & 0 deletions .changeset/route-modules-router.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@tanstack/router-core': minor
'@tanstack/react-router': minor
'@tanstack/solid-router': minor
'@tanstack/vue-router': minor
---

Experimental: Add route modules: workspace packages that own a subtree of file-based routes and are mounted into applications or other modules. The generated host route tree mounts a module root under a host route and type-checks the mount: a static mount path, no required search params above the module, the router context the module requires, and serializable lifecycle results in server-rendered applications. Module routes, links, navigation, redirects and hooks come from the module's generated route scope and take module-local paths and qualified route ids wherever the module is mounted; `getRouteApi` and route-bound hooks resolve the nearest installation. A module mounted under path params keeps the params of the current location in its own links, and `HostedRouter` types the links of code that mounts it. A module installed several times gets one copy of its routes per installation, with ids `<package>#<as>:/…`; module-local ids, destinations, redirects and not-found errors resolve to the installation of the route that uses them, and `InstallationRoutesById` types an installation's routes. Matches of module routes carry `localRouteId`, the installation-independent id, and the generated `isScopedMatch` guard narrows whole-router matches to the routes of a scope. Applications without route modules are unaffected.
9 changes: 9 additions & 0 deletions .changeset/route-modules-start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@tanstack/start-client-core': minor
'@tanstack/start-plugin-core': minor
'@tanstack/react-start': minor
'@tanstack/solid-start': minor
'@tanstack/vue-start': minor
---

Experimental: Support route modules in TanStack Start. A module that depends on the Start framework package gets `createServerFn`, `createMiddleware` and `createStartModule` in its generated route scope. It declares the context it requires from the application by augmenting `StartModuleRequirements`, keyed by its package name, with `requestContext` and `functionContext`; the declaration emits no JavaScript. A module that contributes serialization adapters or middleware exports a fragment created with `createStartModule` from `start.ts`, and applications install the generated list with `createStart(() => ({ extends: startModules }))`; the application's own entries run first and entries are deduplicated by identity. The generated `startModules.gen.ts` type-checks that the application installs every fragment and provides the required context. The Start plugin lists module routes in the routes manifest, selects the providers' client tree views for client builds, discovers prerenderable module pages and extends import protection to installed module packages.
10 changes: 10 additions & 0 deletions .changeset/router-core-extensions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@tanstack/router-core': minor
'@tanstack/react-router': minor
'@tanstack/solid-router': minor
'@tanstack/vue-router': minor
'@tanstack/start-client-core': patch
'@tanstack/react-start-rsc': patch
---

Declarations emitted by packages that use the router now import router types from the framework package, for example `@tanstack/react-router`, instead of `@tanstack/router-core`, which pnpm does not let those packages resolve unless they depend on it. The framework packages augment the new `@tanstack/router-core/extensions` entry instead of `@tanstack/router-core`, and the router packages export router-core's `Route` interface, which `createFileRoute` returns, as `RouteCore`. Existing augmentations of `@tanstack/router-core` keep working.
5 changes: 5 additions & 0 deletions .changeset/salty-dryers-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/router-generator': patch
---

Use the package name as the route module's identity. Remove the experimental custom module ID override so generated routes and consumer scopes use the same identity.
5 changes: 5 additions & 0 deletions .changeset/start-modules-many-fragments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/start-client-core': patch
---

Type-check `createStart(() => ({ extends: startModules }))` for applications that install the Start fragments of many route modules. With about 50 fragments, TypeScript reported "Type instantiation is excessively deep and possibly infinite".
5 changes: 5 additions & 0 deletions .changeset/start-rsbuild-compiler-esm-resolve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/start-plugin-core': patch
---

Rsbuild: the Start compiler resolves the imports it follows, such as those of a module that re-exports `createServerFn`, as ES module imports. It used the loader's base resolver, so packages whose exports only list `import`, like `@tanstack/react-start`, failed to resolve and the build stopped.
16 changes: 16 additions & 0 deletions .changeset/true-houses-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
'@tanstack/router-core': patch
'@tanstack/react-router': patch
'@tanstack/solid-router': patch
'@tanstack/vue-router': patch
'@tanstack/router-devtools-core': patch
'@tanstack/router-cli': patch
'@tanstack/router-generator': patch
'@tanstack/start-client-core': patch
'@tanstack/start-plugin-core': patch
'@tanstack/react-start': patch
'@tanstack/solid-start': patch
'@tanstack/vue-start': patch
---

Correct experimental route-module installation identity, scope ownership, framework navigation parity, and Start context validation. Generate independently tree-shakeable scope APIs and explicit dependency namespaces, and keep module composition helpers internal. Use ordinary TypeScript declaration builds, refresh route topology during development, and include provider routes in Start client pruning and prerender discovery.
3 changes: 3 additions & 0 deletions benchmarks/bundle-size/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ node_modules
dist
dist-debug
scenarios/*/src/routeTree.gen.ts
# Generated by the route-module scenarios.
scenarios/*/src/*.gen.*
modules/*/src/*.gen.*

results/*.json
results/*.md
Expand Down
15 changes: 15 additions & 0 deletions benchmarks/bundle-size/modules/feature/generate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { fileURLToPath } from 'node:url'
import { Generator, getConfig } from '@tanstack/router-generator'

const root = fileURLToPath(new URL('.', import.meta.url))

/**
* Generates and publishes the route module, like `tsr generate` in the
* module's package: an application can only mount a generated module.
*/
export async function generateFeatureModule() {
await new Generator({
root,
config: getConfig({ disableLogging: true, target: 'react' }, root),
}).run()
}
19 changes: 19 additions & 0 deletions benchmarks/bundle-size/modules/feature/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "@benchmarks/feature",
"private": true,
"type": "module",
"sideEffects": false,
"tanstack": {
"router": {
"module": true
}
},
"exports": {
"./route-module": "./src/routeModule.gen.ts",
"./package.json": "./package.json"
},
"dependencies": {
"@tanstack/react-router": "workspace:^",
"react": "^19.0.0"
}
}
15 changes: 15 additions & 0 deletions benchmarks/bundle-size/modules/feature/src/routes/__root.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Outlet } from '@tanstack/react-router'
import { Link, createModuleRoot } from '../routeScope.gen'

export const Route = createModuleRoot()({
component: FeatureLayout,
})

function FeatureLayout() {
return (
<>
<Link to="/">Feature home</Link>
<Outlet />
</>
)
}
20 changes: 20 additions & 0 deletions benchmarks/bundle-size/modules/feature/src/routes/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { createFileRoute, useLocation, useMatch } from '../routeScope.gen'

export const Route = createFileRoute('@benchmarks/feature:/')({
component: FeatureIndex,
})

// Reads the router through the module's scope: a framework hook and an
// id-based hook that takes the module's own route ids.
function FeatureIndex() {
const pathname = useLocation({ select: (location) => location.pathname })
const routeId = useMatch({
from: '@benchmarks/feature:/',
select: (match) => match.routeId,
})
return (
<div>
{routeId} {pathname}
</div>
)
}
2 changes: 2 additions & 0 deletions benchmarks/bundle-size/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
}
},
"dependencies": {
"@benchmarks/feature": "workspace:*",
"@tanstack/react-router": "workspace:^",
"@tanstack/react-router-ssr-query": "workspace:^",
"@tanstack/solid-router": "workspace:^",
Expand All @@ -70,6 +71,7 @@
"devDependencies": {
"@rsbuild/core": "^2.3.1",
"@rsbuild/plugin-react": "^2.0.0",
"@tanstack/router-generator": "workspace:^",
"@tanstack/router-plugin": "workspace:^",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>react-router-minimal</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import ReactDOM from 'react-dom/client'
import { RouterProvider, createRouter } from '@tanstack/react-router'
import { routeTree } from './routeTree.gen'

const router = createRouter({ routeTree })

declare module '@tanstack/react-router' {
interface Register {
router: typeof router
}
}

const rootElement = document.getElementById('app')
if (!rootElement) {
throw new Error('Root element `#app` not found')
}
if (!rootElement.innerHTML) {
ReactDOM.createRoot(rootElement).render(<RouterProvider router={router} />)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Outlet, createRootRoute } from '@tanstack/react-router'

export const Route = createRootRoute({
component: RootComponent,
})

function RootComponent() {
return <Outlet />
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { createFileRoute } from '@tanstack/react-router'
import { feature } from '../routeScope.gen'

export const Route = createFileRoute('/')({
component: IndexComponent,
})

// Links into the mounted route module through its namespace.
function IndexComponent() {
return <feature.Link to="/">Feature</feature.Link>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { tanstackRouter } from '@tanstack/router-plugin/vite'
import { generateFeatureModule } from '../../modules/feature/generate'

// The minimal app with a mounted route module, which must be generated first.
await generateFeatureModule()

export default defineConfig({
plugins: [
tanstackRouter({
target: 'react',
autoCodeSplitting: true,
routeModules: {
includes: [{ module: '@benchmarks/feature', at: '/feature' }],
},
}),
react(),
],
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { createRouter } from '@tanstack/react-router'
import { routeTree } from './routeTree.gen'

export function getRouter() {
return createRouter({
routeTree,
scrollRestoration: true,
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {
HeadContent,
Outlet,
Scripts,
createRootRoute,
} from '@tanstack/react-router'

export const Route = createRootRoute({
component: RootComponent,
})

function RootComponent() {
return (
<html>
<head>
<HeadContent />
</head>
<body>
<Outlet />
<Scripts />
</body>
</html>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { createFileRoute } from '@tanstack/react-router'
import { feature } from '../routeScope.gen'

export const Route = createFileRoute('/')({
component: IndexComponent,
})

// Links into the mounted route module through its namespace.
function IndexComponent() {
return <feature.Link to="/">Feature</feature.Link>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { defineConfig } from 'vite'
import viteReact from '@vitejs/plugin-react'
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import { generateFeatureModule } from '../../modules/feature/generate'

// The minimal app with a mounted route module, which must be generated first.
await generateFeatureModule()

export default defineConfig({
plugins: [
tanstackStart({
router: {
routeModules: {
includes: [{ module: '@benchmarks/feature', at: '/feature' }],
},
},
}),
viteReact(),
],
})
9 changes: 9 additions & 0 deletions benchmarks/client-nav/link-performance/cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ export const LINK_CASES = [
label: 'Relative targets',
description: 'Parent and child targets inherit current params and search.',
},
{
id: 'route-bound',
label: 'Route-bound relative targets',
description:
'The relative case through Route.Link, which resolves from its route.',
},
{
id: 'middleware',
label: 'Search middleware chain',
Expand Down Expand Up @@ -103,6 +109,7 @@ export function sourceSearch(
switch (caseId) {
case 'location-updaters':
case 'relative':
case 'route-bound':
case 'middleware':
case 'active':
return {
Expand Down Expand Up @@ -157,6 +164,7 @@ function url(pathname: string, search: Partial<LinkSearch> = {}, hash = '') {
function sourcePath(caseId: LinkCaseId, stateIndex: number) {
switch (caseId) {
case 'relative':
case 'route-bound':
return `/teams/team-${stateIndex}/item-${stateIndex}`
case 'numeric-params':
return `/numbers/${stateIndex}`
Expand Down Expand Up @@ -210,6 +218,7 @@ function expectedHref(caseId: LinkCaseId, stateIndex: number, index: number) {
`source-${stateIndex}-link-${index % 5}`,
)
case 'relative':
case 'route-bound':
return url(
index % 2 === 0
? `/teams/team-${stateIndex}`
Expand Down
Loading
Loading