Clone the repo and then node ./setup.js 'My App Name'
https://react-express-mongoose-demo.herokuapp.com/
This is a boilerplate based on react-scripts
.
It's a mix of React Hooks
, Express
, Mongoose
and Passport
. It uses cookie based authentication
, has role-based client and server routing, and stores some user data in local storage.
-
client-side
react hooks
app- routing
- session management + authentication
- private routes based on auth and roles
- styling with
sass
Input Text
andButton
components
-
server-side
express
withmongo
connection viamongoose
- authentication via
passport
- page routes and API routes based on auth
brypt
password encryption
- Change
.env
values forAPP_SECRET
andDB_URI
- Change the default users to be inserted in the DB from
server/database/_insertDefaultUsers
- this is just for the ability to test the auth mechanism - remove it afterwards and insert your own users. - run
setup.js <your_app_name>
- Remove
setup.js
as it's no longer needed
npm run client
- for client (hot reload)npm start
- for server (no hot reload - you can install nodemon and runnodemon ./server/index
instead)
The app has 2 roles by default (ADMIN & USER), a login/auth mechanism and protected routes based on roles.
It inserts 1 user for each role:
- email:
user@test.com
/ password:password
- email:
admin@test.com
/ password:password