T
TanStack5d ago
flat-fuchsia

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.
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.
React TanStack Router Authenticated Routes Example | TanStack Route...
An example showing how to implement Authenticated Routes in React using TanStack Router.
4 Replies
flat-fuchsia
flat-fuchsiaOP5d ago
Yeah looks like Tanstack is not using the main.tsx file at all So I can't inject the AuthProvider How do I solve ? Looks like the AuthenticatedRoutes example is outdated
harsh-harlequin
harsh-harlequin5d ago
are you using start or router? if start, please use #start-questions and check the start docs
flat-fuchsia
flat-fuchsiaOP5d ago
Thank you, but I can't use Tanstack Router docs on Tanstack Start apps ? I thought it used Tanstack Router without changes I didn't see any big red notices on the Start docs warning me against reading Router docs that's confusing
flat-fuchsia
flat-fuchsiaOP5d ago
This Start docs page: https://tanstack.com/start/latest/docs/framework/react/guide/authentication-overview#examples Under "Client-Side Examples: -> Basic Authentication", it links to https://github.com/TanStack/router/tree/main/examples/react/authenticated-routes which has a main.tsx and not a router.tsx It should work, but the error message doesn't tell me why it doesn't
GitHub
router/examples/react/authenticated-routes at main · TanStack/router
🤖 A client-first, server-capable, fully type-safe router and full-stack framework for the web (React and more). - TanStack/router
Authentication | TanStack Start React Docs
Authentication vs Authorization Authentication: Who is this user? (Login/logout, identity verification) Authorization: What can this user do? (Permissions, roles, access control) Architecture Overview...

Did you find this page helpful?