How to deploy react app on firebase
Let's suppose you are using create-react-app for crating your react app.
Following are the step by step solution to deploy react app on firebase
- Create you React App
- Install Firebase Tool
- Login to Firebase Account
- Initialize Firebase App
- Make a new React Build
- Finally, Deploy on Firebase
Create your react app using - create-react-app command. (Ignore this step, if already installed)
npm install -g create-react-app //Windows sudo npm install -g create-react-app //Linux and Mac create-react-app myReactApp cd myReactApp npm start
Install Firebase Tool globally using - npm install -g firebase-tools command.
npm install -g firebase-tools
Login into your firebase account (for this you need a GMAIL Account)
Now initialize your firebase app, using firebase init command.
Firebase Init has few step you should follow very carefully
Note- Please use space key to choose and enter key to proceed
- Choose Hosting: Configure and deploy Firebase Hosting sites
- Choose [create a new project] - Select an Unique Project Id (it will be shown in your firebase app url)
- What do you want to use as your public directory? (public) - click and remove public and type - build and proceed.
- Configure as a single-page app (rewrite all urls to /index.html)? - Yes
- File build/index.html already exists. Overwrite? - No
Before deploying on firebase make a new build using - npm run build command.
npm run build
Now final step, deploy your react app on firebase.
Now, on terminal you will see a firebase app url like - https://<Firebase_Project_ID>.web.app
After this, use that url using any web browser, Enjoy!