Skip to content

foysalremon/nextauth-mongodb-mongoose

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nextauth on NextJS with Mongoose Model

This example shows how you can use a Mongoose model and connection to support with Next and Next Auth application.

How to use

I have setted all up. Just do:

git clone https://github.com/foysalremon/nextauth-mongodb-mongoose.git

Configuration

Step 1. Get the connection string of your MongoDB server

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.

Step 2. Set up environment variables

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):

Step 3. Run Next.js in development mode

npm install
npm run dev

# or

yarn install
yarn dev

Your app should be up and running on http://localhost:3000!

About

Next Auth v4 with Mongoose Model

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published