A robust authentication service example built using Next.js and NextAuth.js. This project demonstrates how to implement secure user authentication, session management, and OAuth integrations in a modern Next.js application. Developed by Dark Waves.
- Secure Authentication: Implements secure user login with NextAuth.js.
- Session Management: Manage user sessions efficiently.
- OAuth Integration: Easily integrate with providers like Google, GitHub, and more.
- Customizable: Easily adaptable to your project's needs.
-
Clone the Repository
git clone https://github.com/darkwaves-ofc/next-auth-v1.git cd next-auth-v1
-
Install Dependencies
npm install # or yarn install
-
Set Up Environment Variables
Create a
.env
file in the root directory and configure it with the following variables:AUTH_SECRET=your_secret_key NEXT_PUBLIC_APP_URL=http://localhost:3000 # OAuth Providers (example: Google) GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret # OAuth Providers (example: Github) GITHUB_CLIENT_ID=your_github_client_id GITHUB_CLIENT_SECRET=your_github_client_secret # Email Service (Resend-https://resend.com/) RESEND_API_KEY=your_resend_api_key # Database (Prisma-MongoDB) DATABASE_URL=your_database_url
Github and Google OAuth
Link - https://github.com/settings/developers
Homepage URL - YOUR DOMAIN
Authorization callback URL - YOUR DOMAIN/api/auth/callback/github
Link https://console.cloud.google.com/apis/credentials
Homepage URL - YOUR DOMAIN
Authorization callback URL - YOUR DOMAIN/api/auth/callback/google
-
Run the Development Server
npm run dev # or yarn dev
The application will be available at
http://localhost:3000
.
- Open the application in your browser at
http://localhost:3000
. - Click on the login button to sign in using an OAuth provider like Google or GitHub.
- Manage sessions and authenticated routes seamlessly.
next-auth-v1/
├── components/ # Reusable UI components
├── pages/ # Next.js pages
├── styles/ # Global CSS and styles
├── .env.example # Environment variables example
├── public/ # Public assets
│ ├── banner.png # Screenshot 1
│ └── banner2.png # Screenshot 2
└── README.md # Project documentation
- Next.js - React Framework for Production
- NextAuth.js - Authentication for Next.js
- Tailwind CSS - Utility-First CSS Framework
- Resend - Email Service
- Prisma - Database ORM
- MongoDB - Database
Contributions are welcome! If you have suggestions or find a bug, feel free to open an issue or submit a pull request.
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature-name
). - Commit your changes (
git commit -m 'Add your feature'
). - Push to the branch (
git push origin feature/your-feature-name
). - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
Created by Dark Waves.
- Live Demo: [TBD]
- Repository: GitHub
- Documentation: NextAuth.js
Happy Coding!