A modern, secure, and user-friendly authentication system built with Next.js, Tailwind CSS, and MongoDB.
Before you begin, ensure you have the following installed:
git clone https://github.com/wassimOubaziz/PRODIGY_FS_01.git
npm install
or
yarn install
.env.local
file in the root directory and add the following:MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key
npm run dev
or
yarn dev
src/
āāā app/
ā āāā page.js
ā āāā layout.js
ā āāā globals.css
āāā pages/
ā āāā api/
ā ā āāā auth/
ā ā āāā login.js
ā ā āāā register.js
ā ā āāā logout.js
ā āāā login.js
ā āāā register.js
ā āāā dashboard.js
āāā components/
ā āāā Layout.js
ā āāā Navbar.js
ā āāā ClientNavbar.js
ā āāā AuthForm.js
ā āāā Button.js
ā āāā Input.js
āāā lib/
ā āāā mongodb.js
ā āāā auth.js
āāā models/
ā āāā User.js
āāā middleware/
āāā authMiddleware.js
Login: Users can log in using their email and password. Upon successful authentication, a JWT token is generated and stored in the browser's local storage.
Protected Routes: Certain routes (e.g., dashboard) are protected and can only be accessed by authenticated users. The JWT token is used to verify the user's identity.
https://github.com/user-attachments/assets/3d9230f4-bfe6-4306-b150-c7a8cf09ca93
Button
: A reusable button component with consistent styling.Input
: A styled input component for form fields.AuthForm
: A flexible form component used for both login and registration.Navbar
: A responsive navigation bar with dynamic content based on authentication status.This application can be easily deployed to platforms like Vercel or Netlify. Make sure to set up the required environment variables in your deployment platform.
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
This project is MIT licensed.
Wassim Oubaziz