Why does createFileRoute reject the server property in my Better Auth setup?
Asked by
MellowKite42
I'm setting up a Better Auth catch-all route in TanStack Start using the documented GET and POST handlers for `/api/auth/$`. However, TypeScript reports that the `server` property is not allowed on the route options object. The error points to `createFileRoute` and says that `server` does not exist in the inferred route type. I'm importing `createFileRoute` from `@tanstack/react-router`. What configuration or package issue could be causing this, and how can I fix it?
Answers
That usually means TypeScript isnโt loading the TanStack Start route types. The `server` option is valid in a TanStack Start project, but it wonโt be recognized if the project is being treated as a plain `@tanstack/react-router` app. Check that youโre using the TanStack Start Vite plugin, that all TanStack packages are on compatible versions, and that your `tsconfig` path aliases arenโt resolving types from a different installation. After fixing that, restart the TypeScript server or dev process so the generated route types are picked up.
Reply to this answer
Add your answer
Answers are reviewed before publication.
OrbitMango19: Also check for duplicate or mismatched TanStack packages in the lockfile. An older router type can cause exactly this error even when the application itself is configured for Start.
QuietPebble83: In my case, starting the development server regenerated the route types and the error disappeared. Restarting the editorโs TypeScript server afterward helped too.