TanStackT
TanStack2mo ago
7 replies
verbal-lime

Is router.tsx a magic file ? Is it hardcoded on Tanstack router ?

Is src/router.tsx treated as a special file ?
In the Authenticated Routes example, there is no router.tsx, only a main.tsx
https://tanstack.com/router/latest/docs/framework/react/examples/authenticated-routes?panel=code
But when I try to use only the main.tsx file, the app breaks with a very obscure message
error when starting dev server:
Error: Could not resolve entry for router entry: router in PROJECT_ROOT/src
    at resolveEntry (file:///PROJECT_ROOT/node_modules/.pnpm/@tanstack+start-plugin-core_20e71db3acc2f6665e3bbffb20bba9eb/node_modules/@tanstack/start-plugin-core/dist/esm/resolve-entries.js:28:11)
    at BasicMinimalPluginContext.config (file:///PROJECT_ROOT/node_modules/.pnpm/@tanstack+start-plugin-core_20e71db3acc2f6665e3bbffb20bba9eb/node_modules/@tanstack/start-plugin-core/dist/esm/plugin.js:118:32)
    at runConfigHook (file:///PROJECT_ROOT/node_modules/.pnpm/vite@7.2.4_@types+node@22.1_e19ffa8841744488473802535fd7f86b/node_modules/vite/dist/node/chunks/config.js:36577:42)
    at async resolveConfig (file:///PROJECT_ROOT/node_modules/.pnpm/vite@7.2.4_@types+node@22.1_e19ffa8841744488473802535fd7f86b/node_modules/vite/dist/node/chunks/config.js:36085:13)
    at async _createServer (file:///PROJECT_ROOT/node_modules/.pnpm/vite@7.2.4_@types+node@22.1_e19ffa8841744488473802535fd7f86b/node_modules/vite/dist/node/chunks/config.js:26008:67)
    at async CAC.<anonymous> (file:///PROJECT_ROOT/node_modules/.pnpm/vite@7.2.4_@types+node@22.1_e19ffa8841744488473802535fd7f86b/node_modules/vite/dist/node/cli.js:572:18)
 ELIFECYCLE  Command failed with exit code 1.
An example showing how to implement Authenticated Routes in React using TanStack Router.
Was this page helpful?