Skip to main content

Deploying React project to Firebase utilizing Firestore

· 3 min read
Pranjal Kumar
Software Engineer @Bentley-Systems

Deploying with Firebase | Pranjal Blogs | Pranjal Kumar, Hazaribag Jharkhand | SWE Bentley Systems | Software Engineer | Developer | Architect | System Design

Unlock the power of Firebase and Firestore integration to seamlessly deploy your React projects. Streamline your development workflow and harness the scalability of Firebase for efficient deployment.

Before starting with anything make sure you have created your project in FireBase & you have used the same Firebase Config in your `firebase.js` file in your local react project folder

1. Create a build folder using:

npm run build

Building the slug | Pranjal Blogs | Pranjal Kumar, Hazaribag Jharkhand | SWE Bentley Systems | Software Engineer | Developer | Architect | System Design

This in turn will create a build folder in the root of your project folder.

Folder hierarchy | Pranjal Blogs | Pranjal Kumar, Hazaribag Jharkhand | SWE Bentley Systems | Software Engineer | Developer | Architect | System Design

Basically the build files are optimized for production, where there are no ongoing changes in code every now & then.

2. Install the Firebase CLI Tools using:

npm install -g firebase-tools

Installing the firebase tools | Pranjal Blogs | Pranjal Kumar, Hazaribag Jharkhand | SWE Bentley Systems | Software Engineer | Developer | Architect | System Design

`-g` flag is used here to install it globally, so it can be accessed easily from any project.

3. Sign in & initialize

firebase login

Logged into firebase | Pranjal Blogs | Pranjal Kumar, Hazaribag Jharkhand | SWE Bentley Systems | Software Engineer | Developer | Architect | System Design

For logging in, you will be redirected to browser window, there you simply have to login using your FireBase credentials.

firebase init

You will be asked loads & loads of questions while in `firebase init` but don't worry, I will guide you here:

Firebase setup initiated | Pranjal Blogs | Pranjal Kumar, Hazaribag Jharkhand | SWE Bentley Systems | Software Engineer | Developer | Architect | System Design

  1. Are you ready to proceed?

    Type `y`, since we want to continue.

  2. Which Firebase features do you want to set up for this directory? Press Space to select features, then Enter to confirm your choices.

  3. Here, you need to select all features which you included in your project, it may be, you needed nothing & you are just using it for free Hosting. :) In my case, I used Firestore & Storage both in my project & also needed Hosting so, I'm selecting these 3 using space & then press enter.

    Select the desired option | Pranjal Blogs | Pranjal Kumar, Hazaribag Jharkhand | SWE Bentley Systems | Software Engineer | Developer | Architect | System Design

    Make sure to choose the Firebase Hosting, where Github actions are optional.(Refer green stars on above picture).

    When prompted for Firebase rules and other similar stuff, then go with default options.

    Continue selecting the options | Pranjal Blogs | Pranjal Kumar, Hazaribag Jharkhand | SWE Bentley Systems | Software Engineer | Developer | Architect | System Design

    For choosing public directory, make sure you choose the build folder

    Crosscheck the selection | Pranjal Blogs | Pranjal Kumar, Hazaribag Jharkhand | SWE Bentley Systems | Software Engineer | Developer | Architect | System Design

    Go with these options. Make sure you don't overwrite buid/index.html.

    Select storage rules | Pranjal Blogs | Pranjal Kumar, Hazaribag Jharkhand | SWE Bentley Systems | Software Engineer | Developer | Architect | System Design

    4. Deploying our web app

    firebase deploy

    Building and deploying | Pranjal Blogs | Pranjal Kumar, Hazaribag Jharkhand | SWE Bentley Systems | Software Engineer | Developer | Architect | System Design

    Build completed and deployed successfully | Pranjal Blogs | Pranjal Kumar, Hazaribag Jharkhand | SWE Bentley Systems | Software Engineer | Developer | Architect | System Design

    That's it we're done

    Link for the Deployed application will be in the Terminal