Follow these steps to set up the project on your local machine:
Clone the Repository:
git clone https://github.com/CodexParas/credentials-auth-nextjs.git
Install Dependencies:
cd credentials-auth-nextjs
npm install
Create Environment Variables:
Duplicate the .env.sample
file and rename it to .env.local
. Fill in the following values:
MONGODB_URL=your-mongodb-connection-string
NEXTAUTH_URL=your-nextauth-url
NEXTAUTH_SECRET=your-nextauth-secret
Replace your-mongodb-connection-string
, your-nextauth-url
, and your-nextauth-secret
with your actual MongoDB connection string, NextAuth URL, and NextAuth secret, respectively.
Configure MongoDB:
Update the MongoDB connection string in the config/dbConfig.js
file with your own database connection details.
Run the Application:
npm run dev
Open http://localhost:3000 in your browser to see the app.
This starter includes a basic authentication setup using Next Auth with credentials. Customize and extend the authentication flow according to your application's requirements.
src/app/api/auth
directory.src/models/userModel.js
file.src/middleware.js
file.Feel free to build on top of this starter and add more features to suit your project needs.
Happy coding!