Deploy React web-app to Google Firebase
- Tram Ho
Environment and Usage Version: React 17.0.2; NodeJS 14.17.6 ; Windows 10 x64; npx 6.14.15; npm 6.14.15 .
1 2 3 4 5 6 7 | cd D:\ mkdir temp2021_10_03 cd temp2021_10_03 D:\temp2021_10_03>npx create-react-app foo cd foo npm start |
Go http://localhost:3000 to see the results of the newly created web-app.
Go https://firebase.google.com/ account registration.
Go https://firebase.google.com/docs/cli Download Firebase for Windows, about 130 MB. Install Firebase CLI
Firebase CLI installation requires Firebase account login, success message
1 2 | firebase projecs:list |
The result will be similar to the following
Firebase tool can be installed using command
1 2 | npm install -g firebase-tools |
Run command
1 2 | firebase --version |
to see the version number of the installed Firebase tool
1 2 | 9.19.0 |
Initialize the firebase project at the folder containing the React web-app just now
Run command
1 2 | firebase deploy |
View results: https://keyboardshortcuts2019.web.app/
Admin page: https://console.firebase.google.com/project/keyboardshortcuts2019/overview
A blank web-app appears, because the code has not been committed to the repostiory. Therefore, all you need to do is commit the code to the github repository
In package.json
add command
1 2 | "deploy:firebase": "npm run build && firebase deploy" |
1 2 3 4 | git remote add origin https://github.com/donhuvy/firebasetest.git git branch -M main git push -u origin main |
Then continue deploying with the command
1 2 | firebase deploy |
or
1 2 | npm run deploy:firebase |
If you get an error
Treatment https://stackoverflow.com/a/69421211/3728901
Source code: https://github.com/donhuvy/firebasetest