A simple fullstack authentication system with JWT-based login, MongoDB user storage, and a protected dashboard route.
Built for learning, testing, and extending real-world auth flows in fullstack applications. 🔐
This project includes a React frontend, Node.js backend, and MongoDB database connection.
- 🔐 User Registration & Login
- 🔑 Password hashing with bcrypt
- 📦 Token-based authentication with JWT
- 🔐 Protected routes (Dashboard)
- 🚪 Logout functionality
- 📁 Organized code structure for scalability
- 🧪 Tested via Postman
git clone https://github.com/DalaScript/fullstack-auth-app.git
cd fullstack-auth-appcd server
npm installcd ../client
npm installIn the server/ folder, create a .env file and add:
PORT=5000
MONGO_URI=your_mongodb_connection_string
DB_NAME=your_database_name
JWT_SECRET=your_secret_key🔥 You can change the port or JWT secret as needed.
npm startcd ../client
npm startRegisters a new user.
Request Body:
{
"email": "[email protected]",
"password": "yourpassword"
}Logs in a user and returns a token.
Request Body:
{
"email": "[email protected]",
"password": "yourpassword"
}Response:
{
"token": "jwt-token"
}Token is stored in
localStorageon the client side.
- Frontend redirect logic based on auth status
- Token stored securely in
localStorage - Clean and minimalistic UI
- React
- React Router DOM
- Node.js
- MongoDB
- bcryptjs
- jsonwebtoken
- ✅ Add user-specific content after login (e.g., profile, settings)
- 📄 Implement server-side token validation middleware
- 🌐 Form validations & error handling improvements
- 📬 Add forgot password and reset functionality
Feel free to fork and submit issues!
Created by DalaScript 💻