This is a MERN (MongoDB, Express.js, React, Node.js) authentication template that demonstrates how user authentication works in a MERN stack application using JWT (JSON Web Tokens) and bcryptjs for password hashing. This template provides a basic structure and functionality for user registration, login, authentication and profile update, which you can use as a starting point for building your own secure web applications.
- User registration with validation.
- User login with authentication and JWT token generation.
- Secure password hashing using bcryptjs.
- MongoDB integration for storing user data.
- React frontend with form validation and error handling (To be added...)
Before getting started, ensure you have the following dependencies installed on your system:
-
Node.js and npm: Make sure you have Node.js and npm installed on your machine. You can download them from nodejs.org.
-
MongoDB: You should have MongoDB installed and running. You can download and install MongoDB from mongodb.com.
-
Clone the repository to your local machine:
git clone https://github.com/harsh661/mern-auth.git
-
Change into project directory
cd mern-auth
-
Install dependencies
npm install
-
Rename .env-example to .env and add following content:
NODE_ENV=development PORT=5000 MONGODB_URI=your-mongodb-connection-string JWT_SECRET=your-secret-key
-
Start server:
npm run devStart