How to Deploy React App on Firebase
Note - 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 React App
- Install Firebase Tool
- Login to Firebase Account
- Initialize Firebase App
- Make a New React Build and Deploy
Create your react app using - create-react-app command. (Ignore this step, if already installed)
Install Firebase Tool globally using - npm install -g firebase-tools command.
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.
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
Congrats!, You can now use this public firebase url of your app and you can access your app using any web browser.
You may also like: Deploy a react app to a subdirectory