Nextjs authentification
Unanswered
Southeastern blueberry bee posted this in #help-forum
Southeastern blueberry beeOP
Is there a nextjs design pattern for authentication?
Without nextjs-auth0 I'd like to add authentication via a third-party service like google, but for now I'm interested in db authentication directly. I know that my question may seem super confusing, I'm a php junior dev and basically my old applications were built using MVC, so thanks to anyone who can help me clarify this point.
Without nextjs-auth0 I'd like to add authentication via a third-party service like google, but for now I'm interested in db authentication directly. I know that my question may seem super confusing, I'm a php junior dev and basically my old applications were built using MVC, so thanks to anyone who can help me clarify this point.
8 Replies
Southeastern blueberry beeOP
should I see middleware.ts as the controller in MVC, is this the exact equivalent?
no it is a kinda reverse proxy like Nginx, especially when deployed on Vercel platform, it’s deployed Edge network across planet.
you should forget about MVC. I have an experience in C# ASP.NET. Vercel Next.js is completely different architecture so you need change mental model.
hastes make wastes. you want to start with a simple hello world project to change mental model first then challenge complex logic like Auth.js
auth is one of the most tricky stuff in next.js so indeed there is a dedicated channel in this server.
Southeastern blueberry beeOP
@tafutada777 Thank you! Do you have some docs on course to recommend about the nextjs architecture or pattern for simple authentification system i found this https://nextjs.org/docs/pages/building-your-application/routing/authenticating but i didnt found the doc very complete
Southeastern blueberry beeOP
Also It's constantly recommended to use nextauth for this, but I get the feeling that you're required to set up a provider such as Google, github... except that it's not what I'm looking for.
Southeastern blueberry beeOP
Finally I used nextauth using the prisma adapter, the problem was that nextauth requires specific prisma models to work, which was a problem for me because I didn't consider this requirement when designing my MPD, so I had to map my User model to the client table of my db, it works but I lose some interest in using an orm.