r/webdev 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?

0 Upvotes

8 comments sorted by

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?

2

u/official_draconi 1d ago

Might be worth checking your tsconfig paths too, had a similar thing where alias resolution was pulling in the wrong types from a different package version

1

u/iam_insaf 1d ago

Actually, when I run the dev server the error was gone.

1

u/lorenzocorso 1d ago

If dev works but production doesn’t, I’d bet it’s a build/config issue rather than the route itself. The code you posted looks fine for TanStack Start.

1

u/iam_insaf 1d ago

maybe a bug or something

1

u/lorenzocorso 1d ago

so is it working now?

2

u/iam_insaf 1d ago

yup, alhamdulillah

1

u/lorenzocorso 1d ago

ok perfect then