Next.js Discord

Discord Forum

Auth Without an Auth Provider

Unanswered
LaPerm posted this in #help-forum
Open in Discord
LaPermOP
I have my backend in express/node and a Next frontend with app router. I don’t really want to be tied into a 3rd party auth provider. Mainly so I have a better understanding of what’s happening and full control. I’m struggling to find a clear guide on managing auth when using an external backend and not the api routes or using next-auth or kinde or clerk.

I have managed to get something working but it has bugs and would like to see a recommended setup guide

11 Replies

next-auth is just an intermediary lib that joins auth provider and next.js. you should be able to use this with your custom auth backend
Golden paper wasp
Depends on what your auth requirements are. If would say go with simple passwordless route. Use Google auth + magic link email setup.

Simple and easy to set up. If you want I can share the auth guide. I have written it for Astro but you will get the basic idea. There I have covered oauth (google github), Email Password, Passwordless and then setting up 2FA auth.
Honestly auth is quite hard to get it right
Like rate limiting, timing attacks, sending email, password hashing and lot more stuff...
So that's what those 3rd party are charging for. But you can implement on your own.
If you want simple setup then try lucia auth. Also read thier auth guide
@ᴉuɐpɹɐɐ next-auth is just an intermediary lib that joins auth provider and next.js. you should be able to use this with your custom auth backend
LaPermOP
I’ve used it in the past but not with app router I might resort to using it just would have liked to be able to have something I had full control over
you could but its gonna be a bit messy
you can have all the control with next-auth
id say its 80% feature complete
@ᴉuɐpɹɐɐ you can have all the control with next-auth
LaPermOP
I’ve started implementing v5 and to be honest really liking it just trying to find the best way to use my own access tokens as I use them to verify users on the backend