https://github.com/emanuelefavero/mern-authentication
This is a MERN app with passport JS Local Authentication as the backend
https://github.com/emanuelefavero/mern-authentication
express mern mongodb nodejs passport-local passportjs react react-router-dom typescript
Last synced: about 2 months ago
JSON representation
This is a MERN app with passport JS Local Authentication as the backend
- Host: GitHub
- URL: https://github.com/emanuelefavero/mern-authentication
- Owner: emanuelefavero
- Created: 2022-10-24T00:20:51.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-08T22:15:24.000Z (almost 2 years ago)
- Last Synced: 2025-02-04T16:50:29.383Z (3 months ago)
- Topics: express, mern, mongodb, nodejs, passport-local, passportjs, react, react-router-dom, typescript
- Language: TypeScript
- Homepage:
- Size: 472 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# React Router Authentication App
This is a MERN **Authentication** app with passport JS Local Authentication in the backend and [react-router-dom](https://v5.reactrouter.com/web/guides/quick-start) for the frontend routing.
_NOTE: This app is meant to only show how to use Passport JS with React. I would suggest to implement the backend with production ready design patterns such as [MVC](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller), (of course instead of a template language for the view you could use React like we did here)._
## Test the app locally on your machine
> BEWARE: Before you start, make sure the MongoDB Atlas cluster is running and not paused. If it is paused, the app will not work. (My MongodDB Atlas instance for this app is called "Authentication")
- Clone the repo and `cd` into the project directory
- Add a _.env_ file in the root directory with the following variables:```dotenv
MONGODB_URI='YOUR_MONGODB_URI'
SESSION_SECRET_KEY='YOUR_SECRET_KEY'
PORT=4000
```- Run:
```bash
cd backend
yarn install
yarn start
```- Open a new terminal and run:
```bash
cd client
yarn install
yarn start
```- Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
TIP: - Learn more about the session secret key [here](https://stackoverflow.com/questions/5343131/what-is-the-sessions-secret-option)