How to deploy your React app to Firebase

H
andrewgbliss
7 months ago

This article will cover how to deploy your production ready React application to Firebase

. . .

Create a Firebase application

Go to the Firebase console, login, and create your project.

https://console.firebase.google.com/u/0/

Install the Firebase CLI tools

https://www.npmjs.com/package/firebase-tools

npm i -g firebase-tools

Now login from the command line terminal:

firebase login

This will login using the firebase cli tools.

Now run the init command:

firebase init

It will then ask you some question about what to setup.

  • Choose hosting.

  • Then choose the existing project that you have already created in the first step.

What do you want to use as your public directory?

  • Enter build, or whatever folder you build into

Do you want to configure as a single page app?

  • Yes, this is important to run a React app

Overwrite index.html?

  • No, we want to keep the one Create React App created for us.

Build the application

When you are ready to deploy your application you need to build your application.

Run this command to build:

npm run build

Deploy the application

Now that everything is built we can actually deploy to Firebase.

firebase deploy

Conclusion

That wraps up the course on How to build a React App. We now have deployed our app to Firebase and anyone can start using the application.


H
andrewgbliss
7 months ago