ERROR api/auth/sign-in-social
Hi everyone, I am beginner with better-auth. I do setup a Auth with my project but i got error 404 not found. Is there some tip for fix this issue?

7 Replies
There is my auth, auth-client.ts and route.ts




I using Vite
are you using vite? or nextjs?
I am using Vite
Alright assuming you would also have a backend client if you have a frontend client. this is how it should be setup.
the auth handler lives on the server whether this is using a fullstack framework e.g Nextjs, Tanstack, Remix, etc (with api routes) or using a backend service like Hono, Express, etc. this is because it interacts with the database and other sensitive information that shouldn't be on the client
while the authClient (as in the name) lives on the client in this example your vite app. vite by itself (i believe) doesn't support api routes / server rendering unless using a framework / package to handle this.
the
toNextjsHandler()
is for nextjs while it might work depending on the setup, what you need to do is mount the handler to be something like this:
but this is all dependent on your framework and how it defines api routesHi @Jacob , did you have some example with Vite project ( My project Flask Backend, Frontend: Vite react)
I don’t quite have an example for you but I would recommend using either https://reactrouter.com/ (firmly remix) or https://tanstack.com/start/latest (have found this hard to deploy but others seem to have been having an amazing time with it) other of which have examples in the better auth docs .
Since its mostly a client side app the frameworks job is to mainly handle the api route and than you just run your react code the same way
TanStack Start
Full-document SSR, Streaming, Server Functions, bundling and more, powered by TanStack Router and Vite - Ready to deploy to your favorite hosting provider.