How to deploy react app to firebase hosting
I decided to share my experience & best practice that I use in my day-to-day work. Usually, I use this for testing purposes because it is simple. I don’t need to configure the domain, DNS, etc.
This article will help you guys to deploy your react app in firebase hosting through your terminal. I’m using Visual Studio Code as my IDE and PowerShell as my terminal.
- First, log in to firebase then click “Go to console” in the top right of the browser window.
- After getting redirected here, click on “Add project”. Enter the project name then continue until the project is created.
- Move to the terminal, here I’m using VS Code and npm.
- Install the firebase package by typing “npm install firebase” and “npm install -g firebase-tools”
- Login to firebase through the terminal “firebase login”.
- Build the app “npm run build”.
- After building the app, initialize the firebase “firebase init”.
- Configure the firebase.
1. Select hosting.
2. Use existing projects (because we have created one before).
3. Choose the project. For example, my project name is exchanger-1.
4. Select the “build” directory by typing “build”.
5. Select y (to make a single web app).
6. Set up automatic builds and deploys with GitHub. Here I choose no.
7. Override index.html with firebase template index.html? Of course, I choose no.
- After configuring firebase, it’s time to deploy the app “firebase deploy”.
- Done.
That’s all. Hopefully, this article will help me and you guys in the future.