Skip to content

This project is a secure authentication system built using the MERN stack (MongoDB, Express.js, React, Node.js). It provides user registration and login functionality, utilizing JWT (JSON Web Tokens) for secure authentication. Designed with a clear folder structure and proper environment variable handling React,Node, Express, MongoDB, and JWT.

Notifications You must be signed in to change notification settings

AdityaGadbail/MERN-AUTHENTICATION-SYSTEM-USING-JWT-AND-HTTP-ONLY-COOKIE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MERN Authentication System 🔐

A secure and modern full-stack authentication system built using the MERN Stack (MongoDB, Express.js, React.js, Node.js). This project provides robust authentication with JWT, protected routes, and security best practices for real-world production apps.

image image image image

🚀 Features

  • 🔐 JWT (JSON Web Token) Authentication
  • 🔄 User Login & Registration with hashed passwords (bcrypt)
  • Protected Routes for authenticated users only
  • 💾 MongoDB with Mongoose for flexible data models
  • ⚙️ Express.js API with proper middlewares
  • 🌐 React.js Frontend using Context API or Redux
  • 📦 Node.js Backend with modular route handling
  • 📬 Error Handling with user-friendly messages
  • 🧠 Token Storage via HTTP-only cookies or localStorage
  • 🔄 Auto Login on page refresh (token-based auth)
  • 🚫 Logout Functionality
  • 🔐 Secure headers & CORS enabled

🧱 Tech Stack

Frontend:

  • React.js
  • Axios
  • Tailwind CSS
  • React Router DOM

Backend:

  • Node.js
  • Express.js
  • MongoDB (with Mongoose)
  • JSON Web Token (JWT)
  • HTTP-Only cookies
  • Bcrypt for password hashing
  • dotenv for environment variables
  • CORS middleware

🛠️ Installation & Setup

Step 1: Install Dependencies

Install all packages in both client/ and server/ folders:

  • cd client
  • npm i
  • cd server
  • npm i

step 2 : Add .env file

read the .env.example file and create .env file based on the .env.example file

step 3 : For Client - npm run dev

step 4 : For Server - node server.js

About

This project is a secure authentication system built using the MERN stack (MongoDB, Express.js, React, Node.js). It provides user registration and login functionality, utilizing JWT (JSON Web Tokens) for secure authentication. Designed with a clear folder structure and proper environment variable handling React,Node, Express, MongoDB, and JWT.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages