Why does createFileRoute reject the server option in my Better Auth route?
Asked by
MellowCedar47
I'm setting up a Better Auth handler in a TanStack Start application using the documented catch-all route at /api/auth/$. The route uses createFileRoute and defines GET and POST handlers inside a server property, but TypeScript reports that the server property is not allowed on the route options type. How can I configure the project or dependencies so this route is recognized correctly?
Answers
That code is intended for TanStack Start. This error usually means TypeScript is loading the plain TanStack Router route types instead of the Start-specific types, so createFileRoute doesnโt know about the server option. Check that youโre actually using the TanStack Start Vite plugin and that all TanStack packages are installed at compatible versions. A mismatched package can produce this exact error.
Reply to this answer
Add your answer
Answers are reviewed before publication.
QuietMarble29: Also check your tsconfig path and module resolution settings. An alias or duplicate installation can cause TypeScript to load types from a different package version.
PineNova63: In my case, restarting the development server made the error disappear after the dependencies and generated route types were updated.