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 hooksapp- routing
- session management + authentication
- private routes based on auth and roles
- styling with
sass Input TextandButtoncomponents
-
server-side
expresswithmongoconnection viamongoose- authentication via
passport - page routes and API routes based on auth
bryptpassword encryption
- Change
.envvalues forAPP_SECRETandDB_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.jsas 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/indexinstead)
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