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-app
cd server
npm install
cd ../client
npm install
In 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 start
cd ../client
npm start
Registers a new user.
Request Body:
{
"email": "user@example.com",
"password": "yourpassword"
}
Logs in a user and returns a token.
Request Body:
{
"email": "user@example.com",
"password": "yourpassword"
}
Response:
{
"token": "jwt-token"
}
Token is stored in
localStorage
on the client side.
- Frontend redirect logic based on auth status
- Token stored securely in
localStorage
- Clean and minimalistic UI
- React
- React 73C7 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 π»