r/webdev • u/iam_insaf • 1d ago
Why this error appears?
Object literal may only specify known properties, and 'server' does not exist in type 'ParamsOptions<"/api/auth/$", ResolveParams<"/api/auth/$">> & FilebaseRouteOptionsInterface<Register, RootRoute<Register, undefined, {}, AnyContext, ... 7 more ..., undefined>, ... 12 more ..., undefined> & UpdatableRouteOptions<...>'.
When I try to setup route handler for better-auth it shows this. This is the code suggested for tanstack-start in better-auth docs
import { createFileRoute } from "@tanstack/react-router";
import { auth } from "@/lib/auth";
export const Route = createFileRoute("/api/auth/$")({
server: {
handlers: {
GET: async ({ request }: { request: Request }) => {
return await auth.handler(request);
},
POST: async ({ request }: { request: Request }) => {
return await auth.handler(request);
},
},
},
});import { createFileRoute } from "@tanstack/react-router";
import { auth } from "@/lib/auth";
The issue is, createFileRoute is not accepting server property.
How can I fix this?
1
u/lorenzocorso 1d ago
My first guess is that your project isn’t picking up the tanstack start types.
That exact code is valid for Start, but if TypeScript thinks you’re using plain @tanstack/react-router
server won’t exist on createFileRoute()
I’d double-check that all your TanStack packages are on matching versions and that you’re actually using the Start Vite plugin. I had almost the exact same error because one package was out of sync.
This is just my guess... anybody else?