{"id":21273206,"url":"https://github.com/saurabhdhumane/mern-stack-authentication","last_synced_at":"2026-04-12T03:37:12.421Z","repository":{"id":253451202,"uuid":"843492267","full_name":"saurabhdhumane/Mern-Stack-Authentication","owner":"saurabhdhumane","description":"This project is a demonstration of a basic MERN (MongoDB, Express, React, Node.js) stack application  featuring JWT-based authentication and route protection. The application is designed with modern we development practices, ensuring secure and seamless user experiences. ","archived":false,"fork":false,"pushed_at":"2024-08-16T17:52:56.000Z","size":237,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-22T03:09:04.682Z","etag":null,"topics":["authentication","authorization","expressjs","jwt-authentication","jwt-token","mongodb","nodejs","reactjs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/saurabhdhumane.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-16T16:26:56.000Z","updated_at":"2024-08-16T18:03:07.000Z","dependencies_parsed_at":"2024-08-16T20:24:07.826Z","dependency_job_id":null,"html_url":"https://github.com/saurabhdhumane/Mern-Stack-Authentication","commit_stats":null,"previous_names":["saurabhdhumane/mern-stack-authentication"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saurabhdhumane%2FMern-Stack-Authentication","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saurabhdhumane%2FMern-Stack-Authentication/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saurabhdhumane%2FMern-Stack-Authentication/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saurabhdhumane%2FMern-Stack-Authentication/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saurabhdhumane","download_url":"https://codeload.github.com/saurabhdhumane/Mern-Stack-Authentication/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243732252,"owners_count":20338831,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","authorization","expressjs","jwt-authentication","jwt-token","mongodb","nodejs","reactjs"],"created_at":"2024-11-21T09:13:03.635Z","updated_at":"2026-04-12T03:37:07.397Z","avatar_url":"https://github.com/saurabhdhumane.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MERN Authentication and Protected Routes Project\n\nThis project demonstrates a basic MERN (MongoDB, Express, React, Node.js) stack application with JWT-based authentication and route protection. It includes features such as user registration, login, and protected routes. Additionally, it prevents logged-in users from accessing the login and registration pages.\n\n## Features\n\n- **User Authentication**: Users can register, log in, and receive a JWT token for authentication.\n- **Protected Routes**: Certain routes are only accessible to authenticated users.\n- **Public Routes**: Redirects authenticated users away from the login and registration pages.\n- **React Router v6**: Utilizes the latest version of React Router for navigation.\n\n## Installation\n\n1. **Clone the repository**:\n   ```bash\n   git clone https://github.com/saurabhdhumane/Mern-Stack-Authentication.git\n   cd Mern-Stack-Authentication\n   ```\n\n2. **Install dependencies**:\n\n   - Backend (Node.js):\n     ```bash\n     cd backend\n     npm install\n     ```\n   \n   - Frontend (React):\n     ```bash\n     cd frontend\n     npm install\n     ```\n\n3. **Set up environment variables**:\n\n   Create a `.env` file in the `backend` directory with the following contents:\n\n   ```bash\n   # Server Configuration\n   PORT=5000\n\n   # Database Configuration\n   MONGO_URI=mongodb://localhost:27017/mydatabase\n\n   # JWT Configuration\n   JWT_SECRET=mysecretkey\n   JWT_EXPIRES_IN=1h\n   ```\n\n4. **Run the application**:\n\n   - Backend:\n     ```bash\n     cd backend\n     npm start\n     ```\n\n   - Frontend:\n     ```bash\n     cd frontend\n     npm start\n     ```\n\n5. **Access the application**:\n\n   Open your browser and navigate to `http://localhost:3000`.\n\n## Project Structure\n\n- **Backend (Node.js/Express)**: Handles user authentication, JWT token generation, and route protection.\n- **Frontend (React)**: Manages user interaction, routing, and displays pages based on authentication status.\n\n## Routes\n\n### Public Routes\n\n- `/login` - User login page.\n- `/register` - User registration page.\n\n### Protected Routes\n\n- `/dashboard` - Accessible only to authenticated users.\n\n### Home Route\n\n- `/` - A public route that displays the home page.\n\n## Usage\n\n- Register a new user on the `/register` page.\n- Log in with the registered credentials on the `/login` page.\n- After login, you will be redirected to the `/dashboard` page.\n- If logged in, attempting to access `/login` or `/register` will redirect you to the `/dashboard` page.\n- The JWT token is stored in `localStorage` for session persistence.\n\n## Technologies Used\n\n- **Frontend**: React, React Router v6\n- **Backend**: Node.js, Express.js, MongoDB, JWT\n- **Libraries**: `axios`, `jwt-decode`, `dotenv`\n\n## Contributing\n\nFeel free to open issues or submit pull requests if you find any bugs or want to add new features!\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n---\n\nMake sure to replace `your-username/your-repo-name` with the actual GitHub repository URL where you’ll be pushing your code. If you have any specific sections or additional details you’d like to include, feel free to modify this `README.md` file accordingly!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaurabhdhumane%2Fmern-stack-authentication","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaurabhdhumane%2Fmern-stack-authentication","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaurabhdhumane%2Fmern-stack-authentication/lists"}