š MERN Authentication App with Email Verification
This is a secure authentication system built with MERN, TypeScript, and Tailwind CSS featuring email verification, password reset, and JWT authentication.
ā
Email verification with Mailtrap š§
ā
Secure password validation š
ā
Zustand for state management ā”
ā
Smooth animations with Framer Motion š
ā
JWT cookie authentication šŖ
š Features
- User Registration with Validation:
- Password must have at least 6 characters, uppercase, lowercase, number, and special character.
- Email Verification (Mailtrap):
- A verification code is sent upon registration.
- Includes an Account Verification Email Template.
- ā ļø Note: Mailtrap only works for testing purposes and emails can only be received by addresses registered in your Mailtrap account. For production, consider using SendGrid, Mailgun, or AWS SES.
- Automatic Login After Verification.
- Dashboard with User Information:
- Profile details (name, email).
- Account activity (joined date, last login).
- Forgot Password Feature:
- Sends a password reset code via email.
- Includes a Password Reset Email Template.
- JWT Authentication with HTTP-only Cookies.
- Logout Functionality.
- Modern UI with Tailwind CSS and Framer Motion.
š ļø Tech Stack
Frontend
- React (Vite) ā”
- TypeScript
- Tailwind CSS šØ
- Zustand (state management)
- Framer Motion (animations)
- React Hot Toast (notifications)
- Fetch API (for API calls)
- React Router DOM (client-side routing)
Backend
- Node.js + Express.js
- MongoDB + Mongoose
- JWT Authentication
- Mailtrap (email service)
š Installation & Setup
1ļøā£ Clone the Repository
git clone https://github.com/nnerb/mern-auth.git
cd auth-app
2ļøā£ Install Dependencies
Backend
cd server
npm install
Frontend
cd client
npm install
3ļøā£ Set Up Environment Variables
Create a .env file in the backend folder and add:
PORT=5000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_secret_key
MAILTRAP_API_TOKEN=your_mailtrap_api_token
CLIENT_URL=your_client_url
4ļøā£ Run the Application
Backend
cd server
npm run dev
Frontend
cd client
npm run dev
š„ Future Improvements
- ā
Google & GitHub OAuth login
- ā
Two-factor authentication (2FA)
- ā
Dark mode toggle
šŗ Inspiration
This project was inspired by this YouTube tutorial with modifications and enhancements.
š¤ Contributing
Contributions are welcome! Feel free to open an issue or submit a pull request.
š License
This project is licensed under the MIT License.