This example shows how you can use a Mongoose model and connection to support with Next and Next Auth application.
I have setted all up. Just do:
git clone https://github.com/foysalremon/nextauth-mongodb-mongoose.git
In the case of MongoDB Atlas, it should be a string like this:
mongodb+srv://<username>:<password>@my-project-abc123.mongodb.net/test?retryWrites=true&w=majority
For more details, follow this MongoDB Guide on how to connect to MongoDB.
Copy the .env.local.example
file in this directory to .env.local
(which will be ignored by Git):
cp .env.local.example .env.local
Then set each variable on .env.local
(Remove which are not needed there):
MONGODB_URI
should be the MongoDB connection string you got from step 1.SECRET
anything string, can generate one from here.EMAIL_SERVER
checout email provider on next auth.EMAIL_FROM
checout email provider on next auth.GOOGLE_CLIENT_ID
checout google provider on next auth.GOOGLE_CLIENT_SECRET
checout google provider on next auth.FACEBOOK_CLIENT_ID
checout facebook provider on next auth.FACEBOOK_CLIENT_SECRET
checout facebook provider on next auth.GITHUB_CLIENT_ID
checout github provider on next auth.GITHUB_CLIENT_SECRET
checout github provider on next auth.
npm install
npm run dev
# or
yarn install
yarn dev
Your app should be up and running on http://localhost:3000!