0
Fork 0
mirror of https://github.com/TanStack/router.git synced 2026-11-16 19:38:07 +00:00
router/examples
Manuel Schiller 99df5ae424 feat: experimental route modules for file-based routing
Route modules are workspace packages that own a subtree of file-based routes and are mounted into applications or other modules. A package declares `tanstack.router.module` in its package.json. The generator gives it qualified route ids (`<pkg>:<path>`), a generated route scope (`routeScope.gen.ts` plus one namespace file per included or used module), 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`). Includers mount modules with the `routeModules` option: `includes` chooses the host route and mount path, optionally under path params, `uses` references modules mounted elsewhere, and an application installs a module several times by including it once per installation named with `as`, each with its own namespace and route ids (`<pkg>#<as>:<path>`). Matches of module routes carry `localRouteId`, and the generated `isScopedMatch` guard narrows whole-router matches by module id prefix.

Runtime: the generated host tree mounts module roots with the internal `mountRouteModule`; module-local ids, destinations, redirects and not-found errors resolve to the installation of the route that uses them; `HostedRouter` types the links of code that mounts modules under path params. Type composition is contract-based through `./route-types`; the framework packages augment `@tanstack/router-core/extensions` and export `RouteCore`.

Start: modules get `createServerFn`, `createMiddleware` and `createStartModule` in their scope, declare required context by augmenting `StartModuleRequirements`, and contribute fragments that applications install with `createStart(() => ({ extends: startModules }))`; `startModules.gen.ts` type-checks installation and requirements. The Start plugin lists module routes in the routes manifest, selects the providers' client tree views, discovers prerenderable module pages and extends import protection to module packages.

Build and tooling: the host bundler compiles, code-splits and hot-updates module routes, including every installation; `tsr generate` and `tsr watch` are the only commands and packages own their declaration builds; the devtools show modules; the `route-module-imports` ESLint rule enforces scope imports. Fixtures cover React, Solid, Vue and Start with Vite and Rsbuild, and a large example measures builds.
History 2026-11-02 00:02:35 +01:00
..
react feat: experimental route modules for file-based routing 2026-11-02 00:02:35 +01:00
solid ci: Version Packages (#8745) 2026-10-22 22:05:39 +02:00
vue ci: Version Packages (#8745) 2026-10-22 22:05:39 +02:00
AGENTS.md agents (#8258) 2026-09-15 22:36:13 +02:00