A secure and modern full-stack authentication system built with Next.js, TypeScript, and MongoDB. It includes password hashing, JWT-based session management, and email verification using Nodemailer and Mailtrap.
- Full-Stack Integration: Combines a modern frontend and backend for a complete solution.
- Secure Password Hashing: Utilizes
bcryptjs
to hash passwords securely. - JWT Authentication: Implements JSON Web Tokens for session management.
- Email Verification: Sends verification emails using Nodemailer and Mailtrap.
- Database Integration: Efficiently stores user data using MongoDB.
- Type Safety: Written in TypeScript for scalable and maintainable code.
- Node.js (v14+ recommended)
- MongoDB (local or cloud instance)
- Mailtrap account for testing email functionality
-
Clone the Repository:
git clone https://github.com/yourusername/full-stack-authentication.git cd full-stack-authentication
-
Install Dependencies:
npm install
-
Configure Environment Variables:
- Create a
.env
file in the root directory and populate it with the following:MONGODB_URI=<your-mongodb-uri> JWT_SECRET=<your-jwt-secret> MAILTRAP_USER=<your-mailtrap-username> MAILTRAP_PASS=<your-mailtrap-password>
- Create a
-
Run the Development Server:
npm run dev
-
Access the Application: Open http://localhost:3000 in your browser.
full-stack-authentication/
├── components/ # Reusable React components
├── pages/ # Next.js pages (API and frontend)
├── utils/ # Utility functions (e.g., JWT handling)
├── models/ # MongoDB models
├── styles/ # CSS/SCSS files
├── .env # Environment variables
└── README.md # Project documentation
- Add social authentication (Google, GitHub, etc.).
- Implement password recovery functionality.
- Improve UI/UX with a modern design framework.
Contributions are welcome! To contribute:
- Fork the repository.
- Create a feature branch (
git checkout -b feature-name
). - Commit your changes (
git commit -m "Add new feature"
). - Push to the branch (
git push origin feature-name
). - Open a pull request.
This project is open-source and available under the MIT License.
Note: This project is intended for educational purposes. Please review and enhance security measures before using it in a production environment.