You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] --router-only main.tsx ignores getRouter() from router.tsx (router.tsx becomes dead code + duplicate Register declaration) #480
When scaffolding a Router-only SPA (create --router-only), the generated src/router.tsx exports a getRouter() factory, but the generated src/main.tsx does not use it. Instead, main.tsx builds its own router inline with createRouter(...).
As a result:
router.tsx / getRouter() is dead code - nothing imports it anywhere in a --router-only project.
The declare module '@tanstack/react-router' { interface Register { ... } } block is duplicated in both main.tsx (router: typeof router) and router.tsx (router: ReturnType<typeof getRouter>).
In the default (TanStack Start) mode this is fine because Start consumes getRouter() from router.tsx as the entry, and main.tsx is not generated. But in --router-only mode the two files diverge and router.tsx is left orphaned.
Your Example Website or App
pnpx @tanstack/cli create --router-only
Steps to Reproduce the Bug or Issue
pnpx @tanstack/cli create --router-only
Open src/main.tsx and src/router.tsx
Grep the project for getRouter -> only defined in router.tsx, never imported
(No StackBlitz needed - this is reproducible purely from the CLI output.)
Expected behavior
In --router-only mode, main.tsx should import and use getRouter() from router.tsx, and the Register module augmentation should live in a single place (router.tsx). Something like:
This keeps a single source of truth for router configuration across both Start and Router-only modes, removes the dead getRouter(), and removes the duplicate Register declaration.
Activity
shonebinu commentedon Jul 22, 2026
ah, so it was an issue with the template. i'm new to this ecosystem and i could not figure out what was going on