Handling auth on server-side?
I'm using React Router v7 (Remix), and I want to authenticate on the server. But it seems like BE doesn't support server-side auth. Is this really so?
Solution:Jump to solution
This works in a server action: https://www.better-auth.com/docs/concepts/api#error-handling
API | Better Auth
Better Auth API.
14 Replies
wdym?
you can use
auth.api
If I understand correctly, then you're opting out of all cookie/session management. I don't see any helpers on the api or docs for working with them without building a lot of authentication from scratch.
auth.api works great for server sided auth, however you'll be missing built in rate limiting
This example is not really how to integrate with Remix, but with a react SPA:
https://www.better-auth.com/docs/integrations/remix
Remix Integration | Better Auth
Integrate Better Auth with Remix.
Is there a good example anywhere of working on the server with BE?
GitHub
better-auth/examples/remix-example at main · better-auth/better-auth
The most comprehensive authentication framework for TypeScript - better-auth/better-auth
you can check this
That's also using client-side methods.
client-side and server-side api's almost same
authClient.updateUser()
auth.api.updateUser()
Its always like this
maybe i missunderstanding youLet's say I wanted to authenticate the user as the result of a fom post, then set-cookie. What does that look like?
Solution
This works in a server action: https://www.better-auth.com/docs/concepts/api#error-handling
API | Better Auth
Better Auth API.
Also you can check this page
https://www.better-auth.com/docs/concepts/api
API | Better Auth
Better Auth API.
Ahh, that's what I'm looking for. Thank you.
Is it only rate limiting I'm otherwise missing out on?
i’m 90% sure yes, the rest should be handled no problem