This repository contains a full-stack web application built with ReactJS for the frontend and Node.js, Express, and MongoDB for the backend. The project focuses on implementing authentication features.
- Frontend: ReactJS
- Backend: Node.js, Express
- Database: MongoDB
- Libraries: bcryptjs, jsonwebtoken (JWT), cookies
- React Hooks: useState,useHistory, useNavigate
This project demonstrates the integration of frontend and backend technologies to create a secure authentication system using JSON Web Tokens (JWT) and secure cookie storage. The backend handles user registration, login, and authentication, while the frontend provides a user-friendly interface for these functionalities.
- Authentication: User registration and login using encrypted passwords stored in MongoDB.
- Secure Cookies: Storing JWT tokens securely in HTTP-only cookies to prevent client-side access.
- React Integration: Frontend communicates with the backend API using axios for HTTP requests.
Throughout this project, we gained insights into various aspects of backend development:
- Security: Implementing password hashing with bcryptjs for secure storage.
- Authentication: Using JWT to manage user sessions and ensure secure communication between frontend and backend.
- Frontend-Backend Integration: Integrating ReactJS with Node.js and Express to create a seamless user experience.
- React Hooks: Utilizing useHistory and useNavigate (for react-router-dom v6>) hooks for client-side navigation after authentication.
- Clone the repository:
git clone https://github.com/adarshsingh1706/Auth - Navigate to the project directory:
cd project-directory - Install dependencies:
- Backend:
cd backend && npm install - Frontend:
cd frontend && npm install - Set up environment variables:
- Create a
.envfile in the backend directory and define necessary variables (e.g., PORT, MONGO_DB_URL, SECRET_KEY). - Start the backend server:
cd backend && npm start - Start the frontend development server:
cd frontend && npm start - Open your browser and go to
http://localhost:4000to view the application.
Contributions are welcome! Please fork the repository and create a pull request with your improvements.
This project is licensed under the MIT License.