https://github.com/letsdeepchat/jwt-authentication
https://github.com/letsdeepchat/jwt-authentication
Last synced: 12 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/letsdeepchat/jwt-authentication
- Owner: letsdeepchat
- Created: 2023-07-28T09:57:52.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-28T10:44:29.000Z (over 2 years ago)
- Last Synced: 2025-02-12T15:40:51.559Z (about 1 year ago)
- Language: JavaScript
- Size: 163 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# JWT Authentication Starter (MERN)

This is a starter app for a MERN stack application with authentication. This is for a SPA (Single Page Application) workflow that uses the [Vite](https://vite.dev) Build tool.
It includes the following:
- Backend API with Express & MongoDB
- Routes for auth, logout, register, profile, update profile
- JWT authentication stored in HTTP-only cookie
- Protected routes and endpoints
- Custom middleware to check JSON web token and store in cookie
- Custom error middleware
- React frontend to register, login, logout, view profile, and update profile
- Applied CRUD operation in home page and filter on email and name basis
- React Bootstrap UI library
- React Toastify notifications
## Usage
- Create a MongoDB database and obtain your `MongoDB URI` - [MongoDB Atlas](https://www.mongodb.com/cloud/atlas/register)
### Env Variables
`.env` contails Mongodb URI and secret key
```
NODE_ENV = development
PORT = 5000
MONGO_URI = your mongodb uri
JWT_SECRET = 'abc123'
```
### Install Dependencies (frontend & backend)
```
npm install
cd frontend
npm install
```
### Run
```
# Run frontend (:3000) & backend (:5000)
npm run dev
# Run backend only
npm run server
```
## Build & Deploy
```
# Create frontend prod build
cd frontend
npm run build
```

