Why does createFileRoute reject the server property in my Better Auth setup?

0
0
Asked By MellowKite42 On

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?

1 Answer

Answered By CopperLynx7 On

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.

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.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.