---
title: "Deploy to Firebase"
description: "Configure CircleCI to deploy to Firebase by installing firebase-tools as a dev dependency and authenticating with a service account."
platform: "Cloud, Server"
doc_version: "Server"
last_updated: "2026-10-06"
---

> For current CircleCI product defaults, deprecated patterns, and Cloud/Server differences, see [AGENTS.md](https://circleci.com/docs/AGENTS.md).
>
> For the complete documentation index and site structure, see [llms.txt](https://circleci.com/docs/llms.txt).

# Deploy to Firebase

In this how-to guide, you will learn how to configure CircleCI to deploy to Firebase.

## Introduction

This page provides a configuration for deployment to Firebase. In order to deploy to Firebase, you will need to add `firebase-tools` to your project’s `devDependencies` since attempting to install `firebase-tools` globally in CircleCI will not work.

## 1\. Install tools

```shell
npm install --save-dev firebase-tools
```

## 2\. Authenticate with a service account

If you have not already done so, [create a Google Cloud service account](https://cloud.google.com/iam/docs/service-accounts-create) with the appropriate access for the deploy job.

Then, [create a service account key](https://cloud.google.com/docs/authentication/provide-credentials-adc#wlif-key). You may store the key file contents in your project’s environment variables (in this guide, we name the project environment variable `$SA_KEY`). Refer to the [Set an Environment Variable in a Project](https://circleci.com/docs/guides/server/security/set-environment-variable/#set-an-environment-variable-in-a-project) guide for instructions. CircleCI will use this credential to authenticate with Firebase.

To take advantage of [Secrets Masking](https://circleci.com/docs/guides/security/contexts/#secrets-masking), it is best practice to set environment variables at the [Project Level](https://circleci.com/docs/guides/security/set-environment-variable/#set-an-environment-variable-in-a-project) or within a [Context](https://circleci.com/docs/guides/security/set-environment-variable/#set-an-environment-variable-in-a-context).

Review the [Google IAM documentation](https://cloud.google.com/iam/docs/best-practices-for-managing-service-account-keys) for best practices in managing service account keys.

## 3\. Declare environment variable inside `run` step

1.  Inside a `run` step, output the value of the environment variable, that is, the contents of the service account key file, to a JSON file.
    
2.  Set the JSON file path as the value of an environment variable `$GOOGLE_APPLICATION_CREDENTIALS` declared in the shell (See [Environment Variables Order of Precedence](https://circleci.com/docs/guides/server/security/env-vars/#order-of-precedence)) guide. Then, run the Firebase deploy command.
    

```yaml
    - run:
        name: Deploy on Firebase
        command: |
          echo $SA_KEY > credentials.json
          GOOGLE_APPLICATION_CREDENTIALS=credentials.json firebase deploy
```

To learn more about how Google finds application credentials, refer to the [documentation for Google Cloud authentication](https://cloud.google.com/docs/authentication/application-default-credentials#GAC).

## Deploy example

The following example shows how you can add a Firebase deploy job to your project’s `.circleci/config.yml` file. The example includes the following:

*   A job to build your application (`build-job`).
    
*   A deployment workflow that only runs the deployment job once the build job has completed **and** you are on the main branch.
    

```yaml
version: 2.1

jobs:
  build-job:
    docker: # Specify executor for running build-job - this example uses a Docker container
      - image: <docker-image-name-tag> # Specify docker image to use
    steps:
      # steps omitted for brevity

  deploy-job:
    docker:
      - image: <docker-image-name-tag>
    working_directory: /tmp/my-project
    steps:
      - run:
          name: Deploy on Firebase
          command: |
            echo $SA_KEY > credentials.json
            GOOGLE_APPLICATION_CREDENTIALS=credentials.json firebase deploy

workflows:
  deploy:
    jobs:
      - build-job
      - deploy-job:
          requires:
            - build-job
          filters: pipeline.git.branch == "main" # only run the deploy-job job on the main branch
```

## Google Cloud Functions

If you are using Cloud Functions with Firebase, do the following:

*   Instruct CircleCI to navigate to the folder where the Cloud Functions are held (in this case 'functions') and run `npm install`.
    
*   Add the following to your `.circleci/config.yml` file:
    
    ```yaml
        - run: cd functions && npm install
    ```