This project was bootstrapped with Create React App.
This project is essentially a demo to document the best practices when developing a React app with firebase.
Below are some of the best practices implemented,
- Basic template with create react app
- Added firebase using
firebase init
- Using vanilla bootstrap dependency
React datepicker
React hook form
React router dom
- .env file to manage firebase keys
- StateProvider to manage state using context
- Custom hook to see user auth status
useAuthStatus
reducer.js
to manage the actions- Login using google signin
- Private routes to make sure user can't just navigate
Create a firebase app and add a .env file in the root of the project.
Set the keys as below
REACT_APP_FIREBASE_API_KEY = <your key>
REACT_APP_FIREBASE_AUTH_DOMAIN=<your key>
REACT_APP_FIREBASE_DATABASE_URL=<your key>
REACT_APP_FIREBASE_PROJECT_ID=<your key>
REACT_APP_FIREBASE_STORAGE_BUCKET=<your key>
REACT_APP_FIREBASE_MESSAGING_SENDER_ID= <your key>
REACT_APP_FIREBASE_APP_ID= <your key>
Next, do npm install
and then npm start
To deploy to firebase,
do npm run build
and then firebase deploy --only hosting