Route file does not export any route piece
Sandbox: https://stackblitz.com/edit/vitejs-vite-hc6bcytw
I created a new React project using Tanstack Router. This is the Vite configuration
Next I created a router.ts
and imported it in the main file
Inside the routes folder I added a root layout and a index.tsx file
When running the app I see the following "error"
Route file "import { createFileRoute } from '@tanstack/react-router'; const Route = createFileRoute('/')({ component: Page, }); function Page() { return <div>React Starter</div>; } export { Route }; " does not export any route piece. This is likely a mistake. Generated route tree in 450msNow the index.tsx file also shows the error
Argument of type '"/"' is not assignable to parameter of type 'undefined'.(2345)and the routeTree.gen.ts file remains empty. What is wrong or missing?
8 Replies
vicious-goldโข3mo ago
you need to use
export const Route
that's what the generator is looking fornational-goldOPโข3mo ago
@Manuel Schiller thanks for your reply, that fixed it! ๐
But my approach used to work before ๐ฆ Has there been a breaking change?
vicious-goldโข3mo ago
it wasnt enforced before but we relied on that
we could make it work for the other syntax but I am not sure it is worth the effort
national-goldOPโข3mo ago
In my other project I separated the page from the route. So the page component was
And the routes file only got
@Manuel Schiller hm yeah, somehow this doesn't work anymore
https://stackblitz.com/edit/vitejs-vite-hcqkqnce
But we still use it in production ๐ค
vicious-goldโข3mo ago
can you please create a GitHub issue for this? then we can see what we can do here
national-goldOPโข3mo ago
sure, no problem ๐ But do you think this is a bug right now.. ?
Can't share the production app code, it's private :/
vicious-goldโข3mo ago
no need to share that
vicious-goldโข3mo ago
fixed that in https://github.com/TanStack/router/releases/tag/v1.121.6
GitHub
Release v1.121.6 ยท TanStack/router
Version 1.121.6 - 6/12/25, 8:43 PM
Changes
Fix
router-generator: allow standalone export (#4405) (35a5103) by Manuel Schiller
Chore
examples: fix duration calculation logic (#4353) (bab29d0) by ...