MERN app: What is the correct approach when integrating NextAuth with multiple auth providers (e.g. AWS Cognito + Facebook + Google) while still using MongoDB to store the rest of my users' data? #3361
-
Hello everyone, I'm building a "MENN" app (Mongo, Express, Nextjs and Nodejs?), and I've decided to use NextAuth to easily integrate multple providers like Facebook, G+ and Amazon Cognito. However I am not quite sure of a proper way to integrate this authorization solution with the app's own users db. If this is kind of a noob question it is because I'm just recently cathing up with NextAuth. Thank you for any help you can give me! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Is this a preexisting application, or a new project you're planning to use NextAuth.js with? If its a new project, I would recommend using the For mongo adapters, we have a See also: |
Beta Was this translation helpful? Give feedback.
Is this a preexisting application, or a new project you're planning to use NextAuth.js with?
If its a new project, I would recommend using the
users
table that is generated by the library in your adapter of choice. You can then extend the user model/schema with any additional fields you may need.For mongo adapters, we have a
mongoose
based one that is built for mongodb. You could also potentially use the prisma adapter as well if you're looking for an ORM layer on top of mongodb as well, im pretty sure prisma began supporting mongo pretty well recently.See also:
https://next-auth.js.org/adapters/mongodb
https://next-auth.js.org/adapters/prisma