The Firebase CLI
([GitHub](https://github.com/firebase/firebase-tools)) provides a
variety of tools for managing, viewing, and deploying to Firebase projects.

**Before using the Firebase CLI,
[set up a Firebase project](https://firebase.google.com/docs/guides).**

## Set up or update the CLI

### Install the Firebase CLI

You can install the Firebase CLI using a method that matches your operating
system, experience level, and/or use case. Regardless of how you install the
CLI, you have access to the same functionality and the `firebase` command.

> [!NOTE]
> **Note:** You can also run Firebase CLI commands in Cloud Shell. [Cloud Shell](https://firebase.google.com/docs/cloud-shell.md.txt) is a browser-based, pre-authenticated command-line environment, accessible from the Firebase console, and comes with the Firebase CLI pre-installed. This makes it a convenient option for getting started quickly, provided you add your project files to the Cloud Shell environment.

[Windows](https://firebase.google.com/docs/cli.md.txt#install-cli-windows)
[macOS](https://firebase.google.com/docs/cli.md.txt#install-cli-mac-linux)
[Linux](https://firebase.google.com/docs/cli.md.txt#install-cli-mac-linux)

#### **Windows**

You can install the Firebase CLI for Windows using one of the following
options:

| **Option** | **Description** | **Recommended for...** |
|---|---|---|
| **standalone binary** | Download the standalone binary for the CLI. Then, you can access the executable to open a shell where you can run the `firebase` command. | New developers <br /> Developers not using or unfamiliar with [Node.js](https://www.nodejs.org/) |
| **npm** | Use npm (the Node Package Manager) to install the CLI and enable the globally available `firebase` command. | Developers using [Node.js](https://www.nodejs.org/) |

### standalone binary

To download and run the binary for the Firebase CLI, follow these steps:

1. Download the
   [Firebase CLI binary for
   Windows](https://firebase.tools/bin/win/instant/latest).

2. Access the binary to open a shell where you can run the `firebase`
   command.

3. Continue to [log in and test the CLI](https://firebase.google.com/docs/cli.md.txt#sign-in-test-cli).

### npm

To use `npm` (the Node Package Manager) to install the
Firebase CLI, follow these steps:

1. Install [Node.js](https://www.nodejs.org/) using
   [nvm-windows](https://github.com/coreybutler/nvm-windows)
   (the Node Version Manager). Installing Node.js automatically installs
   the `npm` command tools.

   > [!NOTE]
   > **Note:** The Firebase CLI requires **Node.js v18.0.0 or later**. Some Firebase features might require specific versions of Node.js, so check each Firebase product's getting started page for any specific Node.js requirements.

2. Install the Firebase CLI via `npm` by running the following command:

   ```
   npm install -g firebase-tools
   ```

   This command enables the globally available `firebase` command.

   > [!NOTE]
   > **Note:** If the `npm install -g firebase-tools` command fails, you might need to [change npm permissions](https://docs.npmjs.com/getting-started/fixing-npm-permissions).

3. Continue to [log in and test the CLI](https://firebase.google.com/docs/cli.md.txt#sign-in-test-cli).

#### **macOS or Linux**

You can install the Firebase CLI for macOS or Linux using one of the
following options:

| **Option** | **Description** | **Recommended for...** |
|---|---|---|
| **automatic install script** | Run a single command that automatically detects your operating system, downloads the latest CLI release, then enables the globally available `firebase` command. | New developers <br /> Developers not using or unfamiliar with [Node.js](https://www.nodejs.org/) <br /> Automated deploys in a [CI/CD](https://en.wikipedia.org/wiki/CI/CD) environment |
| **standalone binary** | Download the standalone binary for the CLI. Then, you can configure and run the binary to suit your workflow. | Fully customizable workflows using the CLI |
| **npm** | Use npm (the Node Package Manager) to install the CLI and enable the globally available `firebase` command. | Developers using [Node.js](https://www.nodejs.org/) |

### auto install script

To install the Firebase CLI using the automatic install script, follow
these steps:

1. Run the following cURL command:

   ```
   curl -sL https://firebase.tools | bash
   ```

   This script automatically detects your operating system, downloads the
   latest Firebase CLI release, then enables the globally available
   `firebase` command.

   > [!NOTE]
   > **Note:** If you experience permission issues when installing on MacOS or Linux, you might need to use `sudo` to grant the script the required permissions: `sudo curl -sL https://firebase.tools | bash`

2. Continue to [log in and test the CLI](https://firebase.google.com/docs/cli.md.txt#sign-in-test-cli).

For more examples and details about the automatic install script, refer to
the script's source code at
[firebase.tools](https://firebase.tools/).

### standalone binary

To download and run the binary for the Firebase CLI that's specific
for your OS, follow these steps:

1. Download the Firebase CLI binary for your OS:
   [macOS](https://firebase.tools/bin/macos/latest) \|
   [Linux](https://firebase.tools/bin/linux/latest)

2. *(Optional)* Set up the globally available `firebase` command.

   1. Make the binary executable by running `chmod +x ./firebase_tools`.
   2. [Add the binary's path to your
      PATH.](https://unix.stackexchange.com/a/26059)

   > [!NOTE]
   > **Note:** If you choose not to set up the `firebase` command, you'll need to access the binary each time you want to run a Firebase CLI command.

3. Continue to [log in and test the CLI](https://firebase.google.com/docs/cli.md.txt#sign-in-test-cli).

### npm

To use `npm` (the Node Package Manager) to install the Firebase CLI,
follow these steps:

1. Install [Node.js](https://www.nodejs.org/) using
   [nvm](https://github.com/creationix/nvm/blob/master/README.md)
   (the Node Version Manager).  
   Installing Node.js automatically installs
   the `npm` command tools.

   > [!NOTE]
   > **Note:** The Firebase CLI requires **Node.js v18.0.0 or later**. Some Firebase features might require specific versions of Node.js, so check each Firebase product's getting started page for any specific Node.js requirements.

2. Install the Firebase CLI via `npm` by running the following command:

   ```
   npm install -g firebase-tools
   ```

   This command enables the globally available `firebase` command.

   > [!NOTE]
   > **Note:** If the `npm install -g firebase-tools` command fails, you might need to [change npm permissions](https://docs.npmjs.com/getting-started/fixing-npm-permissions).

3. Continue to [log in and test the CLI](https://firebase.google.com/docs/cli.md.txt#sign-in-test-cli).

### Log in and test the Firebase CLI

After installing the CLI, you must authenticate. Then you can confirm
authentication by listing your Firebase projects.

1. Log into Firebase using your Google account by running the following
   command:

   ```
   firebase login
   ```

   This command connects your local machine to Firebase and grants you
   access to your Firebase projects.

   > [!NOTE]
   > **Note:** The `firebase login` command opens a web page that connects to `localhost` on your machine. If you're using a remote machine and don't have access to `localhost`, run the command with the flag `--no-localhost`.

   > [!NOTE]
   > **Note:** You can also [use the Firebase CLI with CI systems](https://firebase.google.com/docs/cli.md.txt#cli-ci-systems).

2. Test that the CLI is properly installed and accessing your account by
   listing your Firebase projects. Run the following command:

   ```
   firebase projects:list
   ```

   The displayed list should be the same as the Firebase projects listed in
   the [Firebase console](https://console.firebase.google.com/).

### Update to the latest CLI version

Generally, you want to use the most up-to-date Firebase CLI version.

> [!CAUTION]
> In many cases, new features and bug fixes are available only with the latest version of the Firebase CLI. It's a good practice to frequently update the CLI to its latest version.

How you update the CLI version depends on your operating system and how you
installed the CLI.

### Windows

- **standalone binary** : [Download the new
  version](https://firebase.tools/bin/win/instant/latest), then replace it on your system
- **npm** : Run `npm install -g firebase-tools`

### macOS

- **automatic install script** : Run `curl -sL https://firebase.tools | upgrade=true bash`

  > [!NOTE]
  > **Note:** If you experience permission issues when installing on MacOS or Linux, you might need to use `sudo` to grant the script the required permissions: `sudo curl -sL https://firebase.tools | upgrade=true bash`

- **standalone binary** : [Download the new
  version](https://firebase.tools/bin/macos/latest), then
  replace it on your system

- **npm** : Run `npm install -g firebase-tools`

### Linux

- **automatic install script** : Run `curl -sL https://firebase.tools | upgrade=true bash`

  > [!NOTE]
  > **Note:** If you experience permission issues when installing on MacOS or Linux, you might need to use `sudo` to grant the script the required permissions: `sudo curl -sL https://firebase.tools | upgrade=true bash`

- **standalone binary** : [Download the new
  version](https://firebase.tools/bin/linux/latest), then
  replace it on your system

- **npm** : Run `npm install -g firebase-tools`

### Uninstall the Firebase CLI

How you uninstall the CLI depends on your operating system and how you
installed the CLI.

### Windows

- **standalone binary** : Delete the `firebase.exe` binary that you downloaded.
- **npm** : Run `npm uninstall -g firebase-tools`

### macOS

- **automatic install script** : Run
  `curl -sL https://firebase.tools | uninstall=true bash`

  > [!NOTE]
  > **Note:** If you experience permission issues when uninstalling on MacOS or Linux, you might need to use `sudo` to grant the script the required permissions: `sudo curl -sL https://firebase.tools | uninstall=true bash`

- **standalone binary** : Delete the `firebase` binary that you downloaded.
  If you added its location to your `PATH` environment variable, be sure to
  remove it.

- **npm** : Run `npm uninstall -g firebase-tools`

### Linux

- **automatic install script** : Run
  `curl -sL https://firebase.tools | uninstall=true bash`

  > [!NOTE]
  > **Note:** If you experience permission issues when uninstalling on MacOS or Linux, you might need to use `sudo` to grant the script the required permissions: `sudo curl -sL https://firebase.tools | uninstall=true bash`

- **standalone binary** : Delete the `firebase` binary that you downloaded.
  If you added its location to your `PATH` environment variable, be sure to
  remove it.

- **npm** : Run `npm uninstall -g firebase-tools`

### Use the CLI with CI systems

We recommend that you authenticate using Application Default Credentials when
using the CLI with CI systems.

#### *(Recommended)* Use Application Default Credentials

The Firebase CLI will detect and use Application Default Credentials if
they're set. The simplest way to authenticate the CLI in CI and other
headless environments is to
[set up Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc).

#### *(Legacy)* Use `FIREBASE_TOKEN`

Alternatively, you can authenticate using `FIREBASE_TOKEN`. This is less secure
than Application Default Credentials and is no longer recommended.

1. On a machine with a browser,
   [install the Firebase CLI](https://firebase.google.com/docs/cli.md.txt#install_the_firebase_cli).

2. Start the signin process by running the following command:

   ```
   firebase login:ci
   ```
3. Visit the URL provided, then log in using a Google account.

4. Print a new
   [refresh token](https://developers.google.com/identity/protocols/OAuth2).
   The current CLI session will not be affected.

5. Store the output token in a secure but accessible way in your CI system.

6. Use this token when running `firebase` commands. You can use either of the
   following two options:

   - **Option 1:** Store the token as the environment variable
     `FIREBASE_TOKEN`. Your system will automatically use the token.

   - **Option 2:** Run all `firebase` commands with the
     `--token TOKEN` flag in your CI system.  

     This is the order of precedence for token loading: flag, environment
     variable, desired Firebase project.

> [!NOTE]
> **Note:** On any machine with the Firebase CLI installed, you can immediately revoke access for the specified token by running the following command: `firebase logout --token TOKEN`

## Initialize a Firebase project

Many common tasks performed using the CLI, such as deploying to a Firebase
project, require a **project directory** . You establish a project directory
using the `firebase init` command. A project directory is usually the same
directory as your source control root, and after running `firebase init`, the
directory contains a [`firebase.json`](https://firebase.google.com/docs/cli.md.txt#the_firebasejson_file) configuration
file.

To initialize a new Firebase project, run the following command from within your
app's directory:

```
firebase init
```

> [!NOTE]
> **Note:** The `firebase init` command does not create a new directory. If you're starting a new app, you must first make a directory, then run `firebase init` from within that directory.

The `firebase init` command steps you through setting up your project directory
and some Firebase products. During project initialization, the Firebase CLI
asks you to complete the following tasks:

- Select a default Firebase project.

  This step associates the current project directory with a Firebase project so
  that project-specific commands (like `firebase deploy`) run against the
  appropriate Firebase project.

  It's also possible to
  [associate multiple Firebase projects](https://firebase.google.com/docs/cli.md.txt#project_aliases)
  (such as a staging project and a production project) with the same project
  directory.
- Select Firebase products to set up in your Firebase project.

  This step prompts you to set configurations for specific files for the
  selected products or features. For more details on these configurations, refer
  to the specific product's documentation (for example,
  [Hosting](https://firebase.google.com/docs/hosting/quickstart.md.txt#initialize) or
  [Authentication](https://firebase.google.com/docs/auth/configure-providers-cli.md.txt)). Note that you can always run
  `firebase init` later to set up more Firebase products.

At the end of initialization, Firebase automatically creates the following two
files at the root of your local app directory:

- A [`firebase.json`](https://firebase.google.com/docs/cli.md.txt#the_firebasejson_file) configuration file that lists
  your project configuration.

- A `.firebaserc` file that stores your project
  [aliases](https://firebase.google.com/docs/cli.md.txt#project_aliases).

### The `firebase.json` file

The [`firebase init`](https://firebase.google.com/docs/cli.md.txt#initialize_a_firebase_project) command creates a
`firebase.json` configuration file in the root of your project directory.

The `firebase.json` file is required to
[deploy assets with the Firebase CLI](https://firebase.google.com/docs/cli.md.txt#deployment) because it specifies
which files and settings from your project directory are deployed to your
Firebase project (like Hosting settings, Authentication provider
configurations, security rules, and Cloud Functions configuration).
Since some settings can be defined in either your project
directory or the
Firebase console, make sure that you resolve any potential
[deployment conflicts](https://firebase.google.com/docs/cli.md.txt#deployment_conflicts).

You can [configure most Firebase Hosting options](https://firebase.google.com/docs/hosting/full-config.md.txt)
directly in the `firebase.json` file. However, for other
[Firebase services that can be deployed with the Firebase CLI](https://firebase.google.com/docs/cli.md.txt#deployment),
the `firebase init` command creates specific files where you can define settings
for those services, such as an `index.js` file for Cloud Functions. You can
also set up [predeploy or postdeploy hooks](https://firebase.google.com/docs/cli.md.txt#hooks) in the `firebase.json` file.

> [!NOTE]
> **Note:** If you run `firebase init` again for any Firebase service, the command will overwrite the corresponding section of the `firebase.json` file back to the default configuration for that service.

The following `firebase.json` file is a comprehensive example showing
configuration options for many Firebase services. It also demonstrates features
like multi-codebase Cloud Functions, Local Emulator Suite setup, and
a Remote Config template. Note that a `firebase.json` file for any given
project will only contain configurations for the Firebase services set up for
that specific project (for example, only Firebase Hosting and
Cloud Functions). Adding the `$schema` key enables validation and
autocompletion in many code editors.

```json
    {
      "$schema": "https://raw.githubusercontent.com/firebase/firebase-tools/master/schema/firebase-config.json",
      "hosting": {
        "public": "public",
        "ignore": [
          "firebase.json",
          "**/.*",
          "**/node_modules/**"
        ],
        "cleanUrls": true,
        "trailingSlash": false
      },
      "apphosting": {
        "backendId": "my-app",
        "rootDir": "backend",
        "ignore": [
          "firebase.json",
          "**/.*",
          "**/node_modules/**"
        ]
      },
      "firestore": {
        "rules": "firestore.rules",
        "indexes": "firestore.indexes.json"
      },
      "storage": {
        "rules": "storage.rules"
      },
      "database": {
        "rules": "database.rules.json"
      },
      "dataconnect": {
        "source": "dataconnect",
        "location": "us-central1"
      },
      "functions": [
        {
          "source": "functions",
          "codebase": "default",
          "ignore": [
            "**/.*",
            "**/node_modules/**"
          ],
          "predeploy": [
            "npm --prefix \"$RESOURCE_DIR\" run lint",
            "npm --prefix \"$RESOURCE_DIR\" run build"
          ]
        }
      ],
      "emulators": {
        "auth": {
          "port": 9099
        },
        "functions": {
          "port": 5001
        },
        "firestore": {
          "port": 8080
        },
        "hosting": {
          "port": 5000
        },
        "storage": {
          "port": 9199
        },
        "ui": {
          "enabled": true,
          "port": 4000
        },
        "singleProjectMode": true
      },
      "extensions": {
        "my-storage-resizer": "firebase/storage-resize-images@^0.1.0"
      },
      "auth": {
        "providers": {
          "anonymous": true,
          "emailPassword": true,
          "googleSignIn": {
            "oAuthBrandDisplayName": "My App",
            "supportEmail": "support@myapp.com"
          }
        }
      },
      "remoteconfig": {
        "template": "remoteconfig.template.json"
      }
    }
```

While `firebase.json` is used by default, you can pass the
`--config PATH` flag to specify an alternate
configuration file.

#### Configuration for multiple Cloud Firestore databases

When you run `firebase init`, your `firebase.json` file will contain a single
`firestore` key corresponding to your project's default database, as shown
in the preceding example.

If your project contains multiple Cloud Firestore databases, edit your
`firebase.json` file to associate different Cloud Firestore Security Rules and
database index source files with each database. Modify the file with a
JSON array, with one entry for each database.

```json
      "firestore": [
        {
          "database": "(default)",
          "rules": "firestore.default.rules",
          "indexes": "firestore.default.indexes.json"
        },
        {
          "database": "ecommerce",
          "rules": "firestore.ecommerce.rules",
          "indexes": "firestore.ecommerce.indexes.json"
        }
      ],
```

#### Cloud Functions files to ignore on deploy

At function deployment time, the CLI automatically specifies
a list of files in the `functions` directory to ignore. This
prevents deploying to the backend extraneous files that could
increase the data size of your deployment.

The list of files ignored by default, shown in JSON format, is:

    "ignore": [
      ".git",
      ".runtimeconfig.json",
      "firebase-debug.log",
      "firebase-debug.*.log",
      "node_modules"
    ]

If you add your own custom values for `ignore` in `firebase.json`, make
sure that you keep (or add, if it is missing) the list of files shown in the
preceding list.

## Manage project aliases

You can associate multiple Firebase projects with the same project directory.
For example, you might want to use one Firebase project for staging and another
for production. By using different project environments, you can verify changes
before deploying to production. The `firebase use` command lets you switch
between aliases as well as create new aliases.

### Add a project alias

When you select a Firebase project during [project
initialization](https://firebase.google.com/docs/cli#initialize_a_firebase_project), the project is automatically
assigned the alias of `default`. However, to allow project-specific commands to
run against a different Firebase project but still use the *same* project
directory, run the following command from within your project directory:

```
firebase use --add
```

This command prompts you to select another Firebase project and assign the
project as alias. Alias assignments are written to a `.firebaserc` file inside
your project directory.

### Use project aliases

To use assigned Firebase project aliases, run any of the following commands from
within your project directory.

| Command | Description |
|---|---|
| `firebase use` | View a list of defined aliases for your project directory |
| `firebase use \ PROJECT_ID|ALIAS` | Directs all commands to run against the specified Firebase project. The CLI uses this project as the "active project". |
| `firebase use --clear` | Clears the active project. Run `firebase use PROJECT_ID|ALIAS` to set a new active project before running other CLI commands. |
| `firebase use \ --unalias PROJECT_ALIAS` | Removes an alias from your project directory. |

You can override what's being used as the active project by passing
the `--project` flag with any CLI command. As an example: You can set your
CLI to run against a Firebase project that you've assigned the `staging`
alias. If you want to run a single command against the Firebase project that
you've assigned the `prod` alias, then you can run, for example,
`firebase deploy --project=prod`.

### Source control and project aliases

In general, you should check your `.firebaserc` file into source control to
allow your team to share project aliases. However, for open source projects or
starter templates, you should generally not check in your `.firebaserc` file.

If you have a development project that's for your use only, you can either pass
the `--project` flag with each command or run
`firebase use PROJECT_ID` without assigning an alias to
the Firebase project.

## Serve and test your Firebase project locally

You can view and test your Firebase project on locally hosted URLs before
deploying to production. If you only want to test select features, you can use
a comma-separated list in a flag on the `firebase serve` command.

Run the following command from the root of your local project directory if you
want to do either of the following tasks:

- View the static content for your Firebase-hosted app.
- Use Cloud Functions to [generate dynamic content for
  Firebase Hosting](https://firebase.google.com/docs/hosting/functions) and you want to use your *production (deployed)* HTTP functions to emulate Hosting on a local URL.

```
firebase serve --only hosting
```

#### Emulate your project using *local* HTTP functions

Run any of the following commands from your project directory to emulate your
project using *local* HTTP functions.

- To emulate HTTP functions and hosting for testing on local URLs, use either
  of the following commands:

  ```
  firebase serve
  ```

  ```
  firebase serve --only functions,hosting // uses a flag
  ```
- To emulate HTTP functions only, use the following command:

  ```
  firebase serve --only functions
  ```

#### Test from other local devices

By default, `firebase serve` only responds to requests from `localhost`. This
means that you'll be able to access your hosted content from your computer's web
browser but not from other devices on your network. If you'd like to test from
other local devices, use the `--host` flag, like so:

```
firebase serve --host 0.0.0.0  // accepts requests to any host
```

## Deploy to a Firebase project

The Firebase CLI manages deployment of code and assets to your Firebase
project, including:

- New releases of your Firebase Hosting sites
- New, updated, or existing Cloud Functions for Firebase
- New or updated schemas and connectors for Firebase SQL Connect
- Security Rules for Firebase Realtime Database
- Security Rules for Cloud Storage for Firebase
- Security Rules for Cloud Firestore
- Indexes for Cloud Firestore
- Configuration for Authentication

To deploy to a Firebase project, run the following command from your project
directory:

```
firebase deploy
```

You can optionally add a comment to each of your deployments. This comment will
display with the other deployment information on your project's
[Firebase Hosting page](https://console.firebase.google.com/project/_/hosting/main).
For example:

```
firebase deploy -m "Deploying the best new feature ever."
```

When you use the `firebase deploy` command, be aware of the following:

- To deploy resources from a project directory, the project directory
  **must** have a [`firebase.json`](https://firebase.google.com/docs/cli.md.txt#the_firebasejson_file) file. This file is
  automatically created for you by the
  [`firebase init`](https://firebase.google.com/docs/cli.md.txt#initialize_a_firebase_project) command.

- By default, `firebase deploy` creates a release for *all* deployable resources
  in your project directory. To deploy specific Firebase services or features,
  [use partial deployment](https://firebase.google.com/docs/cli.md.txt#partial_deploys).

### Deploy specific Firebase services

If you only want to deploy specific Firebase services or features, you can use a
comma-separated list in a flag on the `firebase deploy` command. For example,
the following command deploys Firebase Hosting content and
Cloud Storage Security Rules.

```
firebase deploy --only hosting,storage
```

The following table lists the services and features available for partial
deployment. The names in the flags correspond to the keys in your
[`firebase.json`](https://firebase.google.com/docs/cli.md.txt#the_firebasejson_file) configuration file.

| Flag syntax | Service or feature deployed |
|---|---|
| `--only auth` | Authentication provider configuration |
| `--only database` | Firebase Realtime Database Security Rules |
| `--only dataconnect` | Firebase SQL Connect schemas and connectors |
| `--only firestore` | Cloud Firestore Security Rules *and* indexes for all configured databases |
| `--only functions` | Cloud Functions for Firebase |
| `--only hosting` | Firebase Hosting content |
| `--only storage` | Cloud Storage for Firebase Security Rules |

> [!NOTE]
> **Note:** The `--only rules` syntax used by earlier versions of the CLI is deprecated.

#### Deployment conflicts for Security Rules

For Firebase Realtime Database, Cloud Storage for Firebase, and Cloud Firestore,
you can define Security Rules either in your local project directory or in the
[Firebase console](https://console.firebase.google.com/).

> [!NOTE]
> **Note:** **When you
> [deploy security rules using the Firebase CLI](https://firebase.google.com/docs/cli.md.txt#deployment),
> the rules defined in your project directory overwrite any existing rules in the
> Firebase console.** So, if you choose to define or edit your security rules using the Firebase console, make sure that you also update the rules defined in your project directory.

Another option to avoid deployment conflicts is to
[use partial deployment](https://firebase.google.com/docs/cli.md.txt#partial_deploys) and only define Security Rules in
the Firebase console.

### Set up predeploy and postdeploy scripted tasks

You can connect shell scripts to the `firebase deploy` command to perform
predeploy or postdeploy tasks. For example, a predeploy script could
transpile TypeScript code into JavaScript, and a postdeploy hook could notify
administrators of new site content deploys to Firebase Hosting.

To set up predeploy or postdeploy hooks, add bash scripts to your
[`firebase.json`](https://firebase.google.com/docs/cli.md.txt#the_firebasejson_file) configuration file. You can define
brief scripts directly in the `firebase.json` file, or you can reference other
files that are in your project directory.

For example, the following script is the `firebase.json` expression for a
postdeploy task that sends a Slack message upon successful deployment to
Firebase Hosting.

    "hosting": {
      // ...

      "postdeploy": "./messageSlack.sh 'Just deployed to Firebase Hosting'",
      "public": "public"
    }

The `messageSlack.sh` script file resides in the project directory and looks
like this:

```
curl -X POST -H 'Content-type: application/json' --data '{"text":"$1"}'
     \https://SLACK_WEBHOOK_URL
```

You can set up `predeploy` and `postdeploy` hooks for any of the
[assets that you can deploy](https://firebase.google.com/docs/cli.md.txt#deployment). Note that running `firebase deploy`
triggers *all* the predeploy and postdeploy tasks defined in your
`firebase.json` file. To run only those tasks associated with a specific
Firebase service, [use partial deployment commands](https://firebase.google.com/docs/cli.md.txt#partial_deploys).

Both `predeploy` and `postdeploy` hooks print the standard output and error
streams of the scripts to the terminal. For failure cases, note the following:

- If a predeploy hook fails to complete as expected, deployment is canceled.
- If deployment fails for any reason, postdeploy hooks are not triggered.

#### Environment variables

Within scripts running in the predeploy and postdeploy hooks, the following
environment variables are available:

- `$GCLOUD_PROJECT`: The active project's project ID
- `$PROJECT_DIR`: The root directory containing the `firebase.json` file
- `$RESOURCE_DIR`: *(For `hosting` and `functions` scripts only)* The location of the directory that contains the Hosting or Cloud Functions resources to be deployed

### Deployment quotas

It's possible (though unlikely) that you might exceed a quota that limits the
rate or volume of your Firebase deployment operations. For example, when
deploying very large numbers of functions, you might receive an `HTTP 429 Quota`
error message. To solve such issues, try
[using partial deployment](https://firebase.google.com/docs/cli.md.txt#partial_deploys).

### Roll back a deployment

You can roll back a Firebase Hosting deployment from your project's
[Firebase Hosting page](https://console.firebase.google.com/project/_/hosting/main)
by selecting the **Rollback** action for the chosen release.

It's not possible to roll back releases of Security Rules for
Firebase Realtime Database, Cloud Storage for Firebase, or
Cloud Firestore.

## Command reference

This section describes the available commands for the following use cases and
products:

- [CLI administrative commands](https://firebase.google.com/docs/cli.md.txt#admin-commands)
- [Project management commands](https://firebase.google.com/docs/cli.md.txt#management-commands)
- [Deployment and local development](https://firebase.google.com/docs/cli.md.txt#deploy-local-commands)
- [App Distribution commands](https://firebase.google.com/docs/cli.md.txt#appdistro-commands)
- [App Hosting commands](https://firebase.google.com/docs/cli.md.txt#apphosting-commands)
- [Authentication (user management) commands](https://firebase.google.com/docs/cli.md.txt#auth-commands)
- [Cloud Firestore commands](https://firebase.google.com/docs/cli.md.txt#firestore-commands)
- [Cloud Functions for Firebase commands](https://firebase.google.com/docs/cli.md.txt#functions-commands)
- [Crashlytics commands](https://firebase.google.com/docs/cli.md.txt#crashlytics-commands)
- [Extensions commands](https://firebase.google.com/docs/cli.md.txt#extensions-commands)
- [Extensions publisher commands](https://firebase.google.com/docs/cli.md.txt#extensions-publisher-commands)
- [Hosting commands](https://firebase.google.com/docs/cli.md.txt#hosting-commands)
- [Realtime Database commands](https://firebase.google.com/docs/cli.md.txt#rtdb-commands)
- [Remote Config commands](https://firebase.google.com/docs/cli.md.txt#config-commands)
- [SQL Connect commands](https://firebase.google.com/docs/cli.md.txt#sql-connect-commands)

> [!NOTE]
> **Note:** The "Command" column shows the required or recommended arguments and flags for each command, with optional arguments in square brackets (`[...]`). The "Description" column contains detailed information about the command as well as any additional optional flags.   
>
> Run any command with `--help` to see all required and optional arguments as well as any available flags (and their defaults).

### CLI administrative commands

| Command | Description |
|---|---|
| `help` | Display help information about the CLI or specific commands. |
| `init` | Associate and set up a new Firebase project in the current directory. This command creates a [`firebase.json`](https://firebase.google.com/docs/cli.md.txt#the_firebasejson_file) configuration file in the current directory. |
| `login` | Authenticate the CLI with your Google Account. Requires access to a web browser. To log into the CLI in remote environments that don't allow access to `localhost`, use the `--no-localhost` flag. |
| `login:ci` | ***Deprecated.*** Instead, use Application Default Credentials with a Google Cloud service account (`GOOGLE_APPLICATION_CREDENTIALS`). Generate an authentication token for use in non-interactive environments. |
| `login:add` | Log in an additional Google Account. |
| `login:list` | List all authenticated Google Accounts. |
| `login:use \ EMAIL_ADDRESS` | Set the active Google Account. |
| `logout` | Sign out your Google Account from the CLI. |
| `open` | Open a browser to relevant project resources. |
| `projects:list` | List all the Firebase projects to which you have access. |
| `use` | Set the active Firebase project for the CLI. Learn more about [managing project aliases](https://firebase.google.com/docs/cli.md.txt#project_aliases). |

### Project management commands

| Command | Description |
|---|---|
| Management of Firebase projects ||
| `projects:addfirebase` | Add Firebase-specific configurations and enable Firebase-specific services in an *existing* Google Cloud project. |
| `projects:create` | Create a new Google Cloud project, then add Firebase-specific configurations and enable Firebase-specific services to the new project. |
| `projects:list` | List all the Firebase projects to which you have access. |
| Management of Firebase Apps (iOS, Android, Web) ||
| `apps:create` | Create a new Firebase App. |
| `apps:list` | List all the registered Firebase Apps in the active Firebase project. |
| `apps:sdkconfig \ [PLATFORM] \ [FIREBASE_APP_ID]` | Print the Firebase configuration of the specified Firebase App. - <var translate="no">PLATFORM</var> can be `IOS`, `ANDROID`, or `WEB` (case-insensitive). If omitted, the CLI prompts you to select an app from a displayed list of all Firebase Apps in the active Firebase project. If the active Firebase project has only one Firebase App, the CLI automatically selects that app. - <var translate="no">FIREBASE_APP_ID</var> is the App ID of the Firebase App (requires <var translate="no">PLATFORM</var> to be specified first). If omitted, the CLI automatically selects the app if only one matches, or prompts you to select an app if multiple match. If the CLI is running in non-interactive mode: - If the active Firebase project has only one Firebase App, then you can omit both <var translate="no">PLATFORM</var> and <var translate="no">FIREBASE_APP_ID</var>. - If the active Firebase project has multiple Firebase Apps, then you must specify <var translate="no">PLATFORM</var> (and <var translate="no">FIREBASE_APP_ID</var> if the project has more than one Firebase App of that platform type). This command supports the following optional flag: - `-o` or `--out [FILENAME]` Write the configuration output to a file instead of printing it to standard output. If <var translate="no">FILENAME</var> is omitted, defaults to a platform-specific filename (`GoogleService-Info.plist` for iOS, `google-services.json` for Android, or `firebase-js-config.json` for Web). If the target file already exists, the CLI prompts you to confirm overwriting (or fails in non-interactive mode). |
| Management of SHA certificate hashes (Android only) ||
| `apps:android:sha:create \ FIREBASE_ANDROID_APP_ID \ SHA_HASH` | Add the specified SHA certificate hash to the specified Firebase Android App. |
| `apps:android:sha:delete \ FIREBASE_ANDROID_APP_ID \ SHA_ID` | Delete the specified SHA certificate (identified by its <var translate="no">SHA_ID</var> from `apps:android:sha:list`) from the specified Firebase Android App. |
| `apps:android:sha:list \ FIREBASE_ANDROID_APP_ID` | List all the SHA certificate hashes for the specified Firebase Android App. |

### Deployment and local development

These commands let you deploy and interact with your Firebase project.

| Command | Description |
|---|---|
| `deploy` | Deploy code and assets from your project directory to the active Firebase project. This command requires a [`firebase.json`](https://firebase.google.com/docs/cli.md.txt#the_firebasejson_file) configuration file in your project directory. Learn more about [deploying to a Firebase project](https://firebase.google.com/docs/cli.md.txt#deployment). |
| `serve` | Start a local server to test your Firebase Hosting configuration and/or local HTTP Cloud Functions (for example, using `--only hosting` or `--only functions`). This command requires a [`firebase.json`](https://firebase.google.com/docs/cli.md.txt#the_firebasejson_file) configuration file in your project directory. Learn more about [serving and testing locally](https://firebase.google.com/docs/cli.md.txt#test-locally). |

### App Distribution commands

| Command | Description |
|---|---|
| `appdistribution:distribute \ RELEASE_BINARY_FILE \ --app FIREBASE_APP_ID` | Upload the specified release binary file (`.apk`, `.aab`, or `.ipa`) and make it available to testers for the specified Firebase App. |
| `appdistribution:testers:add \ [EMAILS...]` | Add one or more testers (specified as space-separated <var translate="no">EMAILS</var>) to the active Firebase project. If <var translate="no">EMAILS</var> is omitted, you must pass `--file FILE`. This command only *adds* testers who aren't already in the project; it doesn't remove or overwrite existing testers. This command supports the following optional flags: - `--file FILE` Specify a path to a non-empty, comma- or newline-separated file containing the email addresses of testers to add. If both <var translate="no">EMAILS</var> and `--file` are passed, <var translate="no">EMAILS</var> takes precedence. - `--group-alias GROUP_ALIAS` Also add the specified testers to the tester group identified by <var translate="no">GROUP_ALIAS</var>. |
| `appdistribution:testers:remove \ [EMAILS...]` | Remove testers (specified as space-separated <var translate="no">EMAILS</var>) from the active Firebase project. If <var translate="no">EMAILS</var> is omitted, you must pass `--file FILE`. This command supports the following optional flags: - `--file FILE` Specify a path to a comma- or newline-separated file containing tester email addresses to remove. (If both <var translate="no">EMAILS</var> and `--file` are passed, <var translate="no">EMAILS</var> takes precedence.) - `--group-alias GROUP_ALIAS` Remove the specified testers *only* from the tester group identified by <var translate="no">GROUP_ALIAS</var>, rather than removing them from the active Firebase project. |
| `appdistribution:testers:list` | List testers in the active Firebase project. |
| `appdistribution:groups:create \ DISPLAY_NAME \ [GROUP_ALIAS]` | Create a tester group with the specified <var translate="no">DISPLAY_NAME</var> and optional <var translate="no">GROUP_ALIAS</var>. If <var translate="no">GROUP_ALIAS</var> is omitted, an alias is automatically generated from <var translate="no">DISPLAY_NAME</var>. |
| `appdistribution:groups:delete \ GROUP_ALIAS` | Delete the tester group with the specified alias. |
| `appdistribution:groups:list` | List all tester groups in the active Firebase project. |

### App Hosting commands

| Command | Description |
|---|---|
| `apphosting:backends:create \ --backend BACKEND_ID \ --primary-region REGION_NAME \ --app FIREBASE_WEB_APP_ID` | Create the collection of managed resources linked to a single codebase that comprises an App Hosting backend. This command supports the following optional (but recommended) flags: - `--backend BACKEND_ID` Specify the ID for the new App Hosting backend. If omitted in interactive mode, the CLI prompts you to enter a backend ID. - `--primary-region REGION_NAME` Specify the primary region in which to create the App Hosting backend. If omitted in interactive mode, the CLI prompts you to select a location. Learn about [supported locations for App Hosting](https://firebase.google.com/docs/app-hosting/about-app-hosting.md.txt#locations). - `-a` or `--app FIREBASE_WEB_APP_ID` Specify the app ID of an existing Firebase Web App. If omitted, the CLI automatically creates and associates a new Firebase Web App named after <var translate="no">BACKEND_ID</var> (unless the project has reached its Firebase App quota). This command also supports the following optional flags: - `--root-dir ROOT_DIR` Specify your app's root directory relative to your repository. If omitted in interactive mode, the CLI prompts you for the directory (defaults to `/`). - `-s` or `--service-account SERVICE_ACCOUNT` Specify the service account used to run the server. If omitted, defaults to the default App Hosting compute service account. If the CLI is running in non-interactive mode, then *both* `--backend` and `--primary-region` are required. |
| `apphosting:backends:get \ BACKEND_ID` | Retrieve the details, including the public URL, of the specified App Hosting backend. If multiple regions contain a backend with the specified <var translate="no">BACKEND_ID</var>, the CLI logs a warning and prints the first matching backend (note that this command doesn't support the `--location` flag). |
| `apphosting:backends:list` | List all active App Hosting backends in the active Firebase project. |
| `apphosting:backends:delete \ BACKEND_ID` | Delete the specified App Hosting backend. The CLI displays a confirmation prompt before taking action. To skip the confirmation prompt (required in non-interactive mode), pass the following flags: `-f` or `--force`. If multiple regions contain a backend with the specified <var translate="no">BACKEND_ID</var>, the CLI prompts you in interactive mode to select which backend(s) to delete, and fails if `-f` or `--force` is passed (note that this command doesn't support the `--location` flag). |
| `apphosting:rollouts:create \ BACKEND_ID` | Create a manually triggered rollout for the specified App Hosting backend. This command supports the following optional, *mutually exclusive* flags. If neither is provided, the CLI prompts you to select from a list of branches; in non-interactive mode, providing one of these flags is required. - `-b` or `--git-branch BRANCH_NAME` Deploy the latest commit on the specified Git branch. - `-g` or `--git-commit COMMIT_ID` Deploy the specified Git commit. If multiple regions contain a backend with the specified <var translate="no">BACKEND_ID</var>, this command fails in both interactive and non-interactive modes (note that this command doesn't support the `--location` flag). |
| `apphosting:secrets:set \ SECRET_NAME \ --data-file DATA_FILE_PATH` | Create or update a secret in Google Cloud Secret Manager with the specified <var translate="no">SECRET_NAME</var>. This command supports the following optional (but recommended) flag: - `--data-file DATA_FILE_PATH` Specify a path from which to read secret data, or set to `-` to read secret data from standard input. If omitted, the CLI prompts you to enter the secret value (with masked input), or reads from standard input if standard input is piped. This command also supports the following optional flag: - `-l` or `--location REGION_NAME` When creating a new secret, restrict its replication to the specified Google Cloud Secret Manager region. If omitted, Google Cloud Secret Manager uses automatic global replication. (Replication policies can't be changed for existing secrets.) If the CLI is running in non-interactive mode, pass `--data-file DATA_FILE_PATH` (or pipe the secret value to standard input). |
| `apphosting:secrets:grantaccess \ SECRET_NAME` | Grant permissions to the specified secret(s) to a set of user or group emails or to a [backend's service account](https://firebase.google.com/docs/app-hosting/about-app-hosting.md.txt#service-account). The secrets can then be accessed by App Hosting at build or run time. You can pass one or more <var translate="no">SECRET_NAME</var> values, separated by a comma. You must specify either `--emails` or `--backend` (these two flags are mutually exclusive). Grant access to a set of user or group emails: - `-e` or `--emails EMAILS` Specify a comma-separated list of user or group emails which should be granted access to the specified secret(s). Grant access to a backend's service account: - `-b` or `--backend BACKEND_ID` Specify the App Hosting backend whose service account should be granted access to the specified secret(s). - `-l` or `--location REGION_NAME` Specify the region for the App Hosting backend. If omitted, the CLI searches across all regions for the matching <var translate="no">BACKEND_ID</var>; if multiple regions contain a backend with that ID, the CLI prompts you to choose one in interactive mode (in non-interactive mode, `--location` is required). |
| `apphosting:secrets:revokeaccess \ SECRET_NAME` | Revoke permissions to the specified secret(s) from a set of user or group emails or from a [backend's service account](https://firebase.google.com/docs/app-hosting/about-app-hosting.md.txt#service-account). You can pass one or more <var translate="no">SECRET_NAME</var> values, separated by a comma. You must specify either `--emails` or `--backend` (these two flags are mutually exclusive). Revoke access from a set of user or group emails: - `-e` or `--emails EMAILS` Specify a comma-separated list of user or group emails from which to revoke access to the specified secret(s). Revoke access from a backend's service account: - `-b` or `--backend BACKEND_ID` Specify the App Hosting backend whose service account should have access revoked from the specified secret(s). - `-l` or `--location REGION_NAME` Specify the region for the App Hosting backend. If omitted, the CLI searches across all regions for the matching <var translate="no">BACKEND_ID</var>; if multiple regions contain a backend with that ID, the CLI prompts you to choose one in interactive mode (in non-interactive mode, `--location` is required). |
| `apphosting:secrets:describe \ SECRET_NAME` | Retrieve the metadata and versions for the specified secret name. |
| `apphosting:secrets:access \ SECRET_NAME[@VERSION]` | Access the value of the secret for the specified secret name at the specified version. If `[@VERSION]` is omitted, defaults to accessing the latest version. |

### Authentication (user management) commands

| Command | Description |
|---|---|
| `auth:export \ DATA_FILE` | Export the user accounts of the active Firebase project to a JSON or CSV file. For more details, see the ["auth:import and auth:export" page](https://firebase.google.com/docs/cli/auth.md.txt#auth-export). |
| `auth:import \ DATA_FILE` | Import the user accounts from a JSON or CSV file into the active Firebase project. For more details, see the ["auth:import and auth:export" page](https://firebase.google.com/docs/cli/auth.md.txt#auth-import). |

### Cloud Firestore commands

| Command | Description |
|---|---|
| `firestore:locations` | List available locations for Cloud Firestore database instances in the active Firebase project. Learn about available locations for [Standard edition](https://firebase.google.com/docs/firestore/locations.md.txt), [Enterprise edition](https://firebase.google.com/docs/firestore/pipelines/locations.md.txt), and [MongoDB compatibility](https://firebase.google.com/docs/firestore/enterprise/locations.md.txt). |
| `firestore:databases:create \ DATABASE_ID \ --location REGION_NAME` | Create the specified Cloud Firestore database instance (in native mode) in the specified location. Run `firebase firestore:locations` to list the available locations for <var translate="no">REGION_NAME</var>. This command supports the following optional flags: - `--delete-protection DELETION_PROTECTION_STATE` Allow or prevent the deletion of the specified Cloud Firestore database instance. Valid values are `ENABLED` or `DISABLED`. If omitted, defaults to `DISABLED`. - `--point-in-time-recovery PITR_STATE` Set whether point-in-time recovery is enabled for the specified Cloud Firestore database instance. Valid values are `ENABLED` or `DISABLED`. If omitted, defaults to `DISABLED`. - `--edition EDITION` Set the edition for the specified Cloud Firestore database instance. Valid values are `standard` or `enterprise`. If omitted, defaults to `standard`. - `--firestore-data-access ENABLEMENT_STATE` *(Enterprise edition only)* Control Cloud Firestore API availability. Valid values are `ENABLED` or `DISABLED`. If omitted, defaults to `ENABLED` (however, when `--mongodb-compatible-data-access` is `ENABLED`, it defaults to `DISABLED`). - `--mongodb-compatible-data-access ENABLEMENT_STATE` *(Enterprise edition only)* Control MongoDB-compatible API availability. Valid values are `ENABLED` or `DISABLED`. If omitted, defaults to `DISABLED`. - `--realtime-updates ENABLEMENT_STATE` *(Enterprise edition only)* Enable or disable the "Watch" (realtime) feature. Valid values are `ENABLED` or `DISABLED`. If omitted, defaults to `ENABLED` when `--firestore-data-access` is `ENABLED` (otherwise, the server default is used). Setting this flag requires `--firestore-data-access` to be `ENABLED`. |
| `firestore:databases:list` | List all Cloud Firestore database instances in the active Firebase project. |
| `firestore:databases:get \ [DATABASE_ID]` | Retrieve the database configuration for the specified Cloud Firestore database instance. If <var translate="no">DATABASE_ID</var> is omitted, defaults to the active Firebase project's *default* Cloud Firestore database instance. The table output includes the database's `Edition` for all databases. Enterprise data access and realtime updates status fields are only included in raw JSON output when `--json` is passed. |
| `firestore:databases:update \ DATABASE_ID` | Update the database configuration of the specified Cloud Firestore database instance. At least one flag is required (omitted flags retain their current settings). This command supports the following flags: - `--delete-protection DELETION_PROTECTION_STATE` Allow or prevent the deletion of the specified Cloud Firestore database instance. Valid values are `ENABLED` or `DISABLED`. - `--point-in-time-recovery PITR_STATE` Set whether point-in-time recovery is enabled for the specified Cloud Firestore database instance. Valid values are `ENABLED` or `DISABLED`. |
| `firestore:databases:delete \ DATABASE_ID` | Delete the specified Cloud Firestore database instance. The CLI displays a confirmation prompt before taking action. To skip the confirmation prompt (required in non-interactive mode), pass the `--force` flag. (Unlike other commands, `firestore:databases:delete` does not support the `-f` shorthand.) |
| `firestore:indexes` | List all the indexes for a Cloud Firestore database instance. This command supports the following optional flag: - `--database DATABASE_ID` Specify the Cloud Firestore database instance for which to list indexes. If omitted, indexes are listed for the active Firebase project's *default* Cloud Firestore database instance. |
| `firestore:delete \ [PATH]` | Delete documents at the specified database path (<var translate="no">PATH</var>) from a Cloud Firestore database instance. <var translate="no">PATH</var> is required unless `--all-collections` is passed. Deleting a collection or a document that has subcollections fails unless either `-r`/`--recursive` or `--shallow` is passed. Note that deleting Cloud Firestore data using the CLI incurs read and delete costs. For more information, see [Understand Cloud Firestore billing](https://firebase.google.com/docs/firestore/pricing.md.txt). This command supports the following optional flags: - `--database DATABASE_ID` Specify the Cloud Firestore database from which documents should be deleted. If omitted, documents are deleted from the active Firebase project's *default* Cloud Firestore database instance. - `--all-collections` Delete all collections in the database. (Do not pass <var translate="no">PATH</var> when using this flag.) - `-r` or `--recursive` Recursively delete all documents and subcollections at the specified path. (Cannot be passed with `--shallow`.) - `--shallow` Delete only documents at the specified level and ignore documents in subcollections. Be aware that this can leave nested documents orphaned. (Cannot be passed with `-r` or `--recursive`.) The CLI displays a confirmation prompt before taking action. To skip the confirmation prompt (required in non-interactive mode), pass the following flags: `-f` or `--force`. |

### Cloud Functions for Firebase commands

For more information, see the
[environment configuration documentation](https://firebase.google.com/docs/functions/config-env.md.txt).

| Command | Description |
|---|---|
| `functions:config:export` | Export the active Firebase project's legacy `functions.config()` runtime configuration as a single JSON secret in Google Cloud Secret Manager (for use with `defineJsonSecret`). This command supports the following optional flags: - `--secret SECRET_NAME` Specify the name of the secret to create or update in Google Cloud Secret Manager. If omitted, the CLI prompts you to enter a name (defaulting to `FUNCTIONS_CONFIG_EXPORT`). - `-f` or `--force` Use the default secret name (`FUNCTIONS_CONFIG_EXPORT`) without prompting and add a new secret version without confirmation if the secret already exists. (Required to add a new version to an existing secret in non-interactive mode.) |
| `functions:delete \ FUNCTION_NAME...` | Delete one or more specified functions from the active Firebase project. The CLI displays a confirmation prompt before taking action. To skip the confirmation prompt (required in non-interactive mode), pass the following flags: `-f` or `--force`. |
| `functions:list` | List all deployed functions in the active Firebase project. |
| `functions:log` | Read logs from all deployed Cloud Functions in the active Firebase project. |
| `functions:secrets:access \ SECRET_NAME[@VERSION]` | Access the value of the secret for the specified secret name at the specified version. If `[@VERSION]` is omitted, defaults to accessing the latest version. |
| `functions:secrets:destroy \ SECRET_NAME[@VERSION]` | Destroy the specified secret at the specified version. If `[@VERSION]` is omitted, defaults to destroying the latest version. The CLI displays a confirmation prompt before taking action, which automatically confirms in non-interactive mode without `-f` or `--force`. However, if the secret is still bound to active function endpoints, you must pass `-f` or `--force` to destroy it. |
| `functions:secrets:get \ SECRET_NAME` | Retrieve the metadata and versions for the specified secret name. |
| `functions:secrets:prune` | Destroy all unused secrets in the active Firebase project. |
| `functions:secrets:set \ SECRET_NAME` | Create or update the specified secret. |
| `functions:shell` | Start a local interactive shell for testing functions. |
| `functions:config:clone \ --from PROJECT_ID` | ***Deprecated.*** Clone another project's environment into the active Firebase project. Disabled by default. To use this command, first run `firebase experiments:enable legacyRuntimeConfigCommands`. |
| `functions:config:get` | ***Deprecated.*** Retrieve the existing configuration values of the active Firebase project's Cloud Functions. |
| `functions:config:set \ KEY=VALUE...` | ***Deprecated.*** Store runtime configuration values of the active Firebase project's Cloud Functions. Disabled by default. To use this command, first run `firebase experiments:enable legacyRuntimeConfigCommands`. |
| `functions:config:unset \ KEY...` | ***Deprecated.*** Remove values from the active Firebase project's runtime configuration. Disabled by default. To use this command, first run `firebase experiments:enable legacyRuntimeConfigCommands`. |

### Crashlytics commands

| Command | Description |
|---|---|
| `crashlytics:mappingfile:generateid \ --resource-file PATH/TO/ANDROID_RESOURCE.XML` | Generate a unique mapping file ID in the specified Android resource (XML) file. |
| `crashlytics:mappingfile:upload \ --app FIREBASE_APP_ID \ --resource-file PATH/TO/ANDROID_RESOURCE.XML \ PATH/TO/MAPPING_FILE.TXT` | Upload a Proguard-compatible mapping (TXT) file for the specified Firebase App, and associate it with the mapping file ID declared in the specified Android resource (XML) file. |
| `crashlytics:symbols:upload \ --app FIREBASE_APP_ID \ PATH/TO/SYMBOLS...` | Generate a Crashlytics-compatible symbol file for Android native library crashes (for example, Android NDK, or Android builds of Unity or Flutter) and upload it to Firebase servers. This command supports Android only. For iOS dSYMs, use the Apple SDK's `upload-symbols` script. |

### Extensions commands

| Command | Description |
|---|---|
| `ext` | Display information on how to use Firebase Extensions commands. List the extension instances installed in the active project. |
| `ext:configure \ EXTENSION_INSTANCE_ID` | Reconfigure the parameter values of an extension instance in your [extension manifest](https://firebase.google.com/docs/extensions/manifest.md.txt). |
| `ext:info \ PUBLISHER_ID/EXTENSION_ID` | Print detailed information about an extension. |
| `ext:install \ PUBLISHER_ID/EXTENSION_ID` | Add a new instance of an extension into your [extension manifest](https://firebase.google.com/docs/extensions/manifest.md.txt). |
| `ext:sdk:install \ EXTENSION_NAME` | Install SDKs for defining extensions in functions. |
| `ext:list` | List all the extension instances installed in a Firebase project. Print the instance ID for each extension. |
| `ext:uninstall \ EXTENSION_INSTANCE_ID` | Remove an extension instance from your [extension manifest](https://firebase.google.com/docs/extensions/manifest.md.txt). |
| `ext:update \ EXTENSION_INSTANCE_ID \ [UPDATE_SOURCE]` | Update an extension instance to the latest version (or to the specified published <var translate="no">UPDATE_SOURCE</var> version) in your [extension manifest](https://firebase.google.com/docs/extensions/manifest.md.txt). Note that for <var translate="no">UPDATE_SOURCE</var>, local paths and URLs aren't supported. The CLI displays a confirmation prompt before taking action. You can pass `-f` or `--force` to skip this prompt in interactive mode; however, `ext:update` is an interactive-only command and isn't supported in non-interactive mode even with `-f` or `--force`. |
| `ext:export` | Export all installed extension instances from your project to your [extension manifest](https://firebase.google.com/docs/extensions/manifest.md.txt). |

### Extensions publisher commands

| Command | Description |
|---|---|
| `ext:dev:init` | Initialize a skeleton codebase for a new extension in the current directory. |
| `ext:dev:list \ PUBLISHER_ID` | Print a list of all extensions uploaded by a publisher. |
| `ext:dev:register` | ***Disabled.*** Registering new publisher profile IDs is no longer supported. |
| `ext:dev:deprecate \ PUBLISHER_ID/EXTENSION_ID \ [VERSION_PREDICATE]` | [Deprecate](https://firebase.google.com/docs/extensions/publishers/upload-and-publish.md.txt#deprecate) extension versions that match the version predicate. A version predicate can be a single version (such as `1.0.0`), or a range of versions (such as `>1.0.0`). If no version predicate is provided, deprecates all versions of that extension. |
| `ext:dev:undeprecate \ PUBLISHER_ID/EXTENSION_ID \ VERSION_PREDICATE` | [Undeprecate](https://firebase.google.com/docs/extensions/publishers/upload-and-publish.md.txt#deprecate) extension versions that match the version predicate. A version predicate can be a single version (such as `1.0.0`), or a range of versions (such as `>1.0.0`). |
| `ext:dev:upload \ PUBLISHER_ID/EXTENSION_ID` | [Upload a new version of an extension.](https://firebase.google.com/docs/extensions/publishers/upload-and-publish.md.txt#first-upload) |
| `ext:dev:usage \ PUBLISHER_ID` | Display install counts and usage metrics for extensions uploaded by a publisher. |

### Hosting commands

| Command | Description |
|---|---|
| `hosting:disable` | Stop serving Firebase Hosting traffic for a Hosting site. The site's Hosting URL will display a "Site Not Found" message after running this command. This command supports the following optional flag: - `--site SITE_ID` Specify the Hosting site to disable. If omitted, defaults to the active Firebase project's *default* Hosting site. The CLI displays a confirmation prompt before taking action. To skip the confirmation prompt (required in non-interactive mode), pass the following flags: `-f` or `--force`. |
| Management of Hosting sites ||
| `hosting:sites:create \ [SITE_ID]` | Create a new Hosting site using the specified <var translate="no">SITE_ID</var>. If the CLI is running in non-interactive mode, then <var translate="no">SITE_ID</var> is required. This command supports the following optional flag: - `--app FIREBASE_APP_ID` Specify an existing Firebase Web App to associate with the new Hosting site. |
| `hosting:sites:delete \ SITE_ID` | Delete the specified Hosting site. The CLI displays a confirmation prompt before taking action. To skip the confirmation prompt (required in non-interactive mode), pass the following flags: `-f` or `--force`. |
| `hosting:sites:get \ SITE_ID` | Retrieve the details about the specified Hosting site. The table output includes the site ID, default URL, and Firebase Web App ID (if linked). Additional metadata (such as whether the site is the `DEFAULT_SITE` or a `USER_SITE`) is only included in raw JSON output when `--json` is passed. |
| `hosting:sites:list` | List all Hosting sites in the active Firebase project. |
| Management of preview channels ||
| `hosting:channel:create \ [CHANNEL_ID]` | Create a new preview channel for a Hosting site using the specified <var translate="no">CHANNEL_ID</var>. This command doesn't deploy to the channel. If the CLI is running in non-interactive mode, then <var translate="no">CHANNEL_ID</var> is required. This command supports the following optional flag: - `--site SITE_ID` Specify the Hosting site in which to create the preview channel. If omitted, defaults to the active Firebase project's *default* Hosting site. |
| `hosting:channel:delete \ CHANNEL_ID` | Delete the specified preview channel. You cannot delete a site's live channel. This command supports the following optional flag: - `--site SITE_ID` Specify the Hosting site from which to delete the preview channel. If omitted, defaults to the active Firebase project's *default* Hosting site. The CLI displays a confirmation prompt before taking action. To skip the confirmation prompt (required in non-interactive mode), pass the following flags: `-f` or `--force`. |
| `hosting:channel:deploy \ CHANNEL_ID` | Deploy your Hosting content and config to the specified preview channel. If the preview channel doesn't yet exist, this command creates the channel in the Hosting site before deploying to the channel. This command supports the following optional flag: - `--only TARGETS` Specify a comma-separated list of Hosting targets configured in `firebase.json` to deploy to the preview channel. If omitted, deploys to all Hosting sites configured in `firebase.json`. |
| `hosting:channel:list` | List all channels (including the "live" channel) for a Hosting site. This command supports the following optional flag: - `--site SITE_ID` Specify the Hosting site for which to list channels. If omitted, defaults to the active Firebase project's *default* Hosting site. |
| `hosting:channel:open \ [CHANNEL_ID]` | Open a browser to the URL of the specified channel or return the URL if opening in a browser isn't possible. If the CLI is running in non-interactive mode, then <var translate="no">CHANNEL_ID</var> is required. This command supports the following optional flag: - `--site SITE_ID` Specify the Hosting site for the preview channel. If omitted, defaults to the active Firebase project's *default* Hosting site. |
| Version cloning ||
| `hosting:clone \ SOURCE_SITE_ID*:*SOURCE_CHANNEL_ID \ TARGET_SITE_ID*:*TARGET_CHANNEL_ID` | Clone the most recently deployed version on the specified "source" channel to the specified "target" channel. This command also deploys to the specified "target" channel. If the "target" channel doesn't yet exist, this command creates a new preview channel in the "target" Hosting site before deploying to the channel. |
| `hosting:clone \ SOURCE_SITE_ID*@*VERSION_ID \ TARGET_SITE_ID*:*TARGET_CHANNEL_ID` | Clone the specified version to the specified "target" channel. This command also deploys to the specified "target" channel. If the "target" channel doesn't yet exist, this command creates a new preview channel in the "target" Hosting site before deploying to the channel. You can find the <var translate="no">VERSION_ID</var> in the [Hosting dashboard](https://console.firebase.google.com/project/_/hosting/main) of the Firebase console. |

### Realtime Database commands

Note that you can create your initial, default Realtime Database instance in the
Firebase console or by using the
[general `firebase init` workflow](https://firebase.google.com/docs/cli.md.txt#initialize_a_firebase_project) or the
specific `firebase init database` flow.

Once instances are created, you can manage them as described in
[Manage and interact with specific instances using the CLI](https://firebase.google.com/docs/database/usage/sharding.md.txt#manage-interact-with-instances-cli).

| Command | Description |
|---|---|
| `database:get \ PATH` | Retrieve data at the specified database location (<var translate="no">PATH</var>) for a Realtime Database instance and display the data as JSON. Supports querying on indexed data. This command supports the following optional flag: - `--instance DATABASE_NAME` Specify the Realtime Database instance for the action. If omitted, defaults to the active Firebase project's *default* Realtime Database instance. |
| `database:instances:create \ DATABASE_NAME \ --location REGION_NAME` | Create a Realtime Database instance with the specified <var translate="no">DATABASE_NAME</var> in the specified location. This command supports the following optional (but recommended) flag: - `--location REGION_NAME` The location for the Realtime Database instance. Learn about [supported locations for Realtime Database](https://firebase.google.com/docs/database/locations.md.txt). If omitted, defaults to `us-central1`. You can't use this command to create the *default* Realtime Database instance for the active Firebase project. If the project doesn't contain any existing Realtime Database instances, then you're prompted to run the `firebase init` flow to create the project's first Realtime Database instance (the default instance). |
| `database:instances:list` | List all Realtime Database instances in the active Firebase project. This command supports the following optional flag: - `--location REGION_NAME` Specify a specific location to list Realtime Database instances. For available region names, see [Locations for Realtime Database](https://firebase.google.com/docs/database/locations.md.txt). |
| `database:profile` | Build a profile of operations for a Realtime Database instance. For more details, see [Realtime Database operation types](https://firebase.google.com/docs/cli/database-profile.md.txt). This command supports the following optional flag: - `--instance DATABASE_NAME` Specify the Realtime Database instance for the action. If omitted, defaults to the active Firebase project's *default* Realtime Database instance. |
| `database:push \ PATH \ [INFILE]` | Push new data to a list at the specified database location (<var translate="no">PATH</var>) in a Realtime Database instance. Takes input from a file (<var translate="no">INFILE</var>), STDIN, or the `-d` (`--data`) flag. This command supports the following optional flag: - `--instance DATABASE_NAME` Specify the Realtime Database instance for the action. If omitted, defaults to the active Firebase project's *default* Realtime Database instance. |
| `database:remove \ PATH` | Delete all data at the specified database location (<var translate="no">PATH</var>) in a Realtime Database instance. This command supports the following optional flag: - `--instance DATABASE_NAME` Specify the Realtime Database instance for the action. If omitted, defaults to the active Firebase project's *default* Realtime Database instance. The CLI displays a confirmation prompt before taking action. To skip the confirmation prompt (required in non-interactive mode), pass the following flags: `-f` or `--force`. |
| `database:set \ PATH \ [INFILE]` | Replace all data at the specified database location (<var translate="no">PATH</var>) in a Realtime Database instance. Takes input from a file (<var translate="no">INFILE</var>), STDIN, or the `-d` (`--data`) flag. This command supports the following optional flag: - `--instance DATABASE_NAME` Specify the Realtime Database instance for the action. If omitted, defaults to the active Firebase project's *default* Realtime Database instance. The CLI displays a confirmation prompt before taking action. To skip the confirmation prompt (required in non-interactive mode), pass the following flags: `-f` or `--force`. |
| `database:update \ PATH \ [INFILE]` | Perform a partial update at the specified database location (<var translate="no">PATH</var>) in a Realtime Database instance. Takes input from a file (<var translate="no">INFILE</var>), STDIN, or the `-d` (`--data`) flag. This command supports the following optional flag: - `--instance DATABASE_NAME` Specify the Realtime Database instance for the action. If omitted, defaults to the active Firebase project's *default* Realtime Database instance. The CLI displays a confirmation prompt before taking action. To skip the confirmation prompt (required in non-interactive mode), pass the following flags: `-f` or `--force`. |

### Remote Config commands

These commands and their use cases are covered in more detail in
[Modify Remote Config programmatically](https://firebase.google.com/docs/remote-config/automate-rc.md.txt#use-config-cli).

| Command | Description |
|---|---|
| `remoteconfig:versions:list` | List all the versions of the Remote Config template. This command supports the following optional flag: - `--limit NUMBER_OF_VERSIONS` Specify the maximum number of versions to return. Specify `0` to return all existing versions. If omitted, defaults to `10`. |
| `remoteconfig:get \ --version-number VERSION_NUMBER` | Retrieve the details of the Remote Config template at the specified version. This command supports the following optional (but recommended) flags: - `-v` or `--version-number VERSION_NUMBER` Specify the version of the Remote Config template to retrieve. If omitted, defaults to the latest version. - `-o` or `--output FILENAME` Write the output to a JSON file with the specified filename instead of printing it as a table. |
| `remoteconfig:rollback \ --version-number VERSION_NUMBER` | Roll back the Remote Config template to the specified previous version. This command supports the following optional (but recommended) flag: - `-v` or `--version-number VERSION_NUMBER` Specify the version of the Remote Config template to roll back to. If omitted, defaults to the immediate previous version (current version - 1). The CLI displays a confirmation prompt before taking action. To skip the confirmation prompt (required in non-interactive mode), pass the following flags: `-f` or `--force`. |
| `remoteconfig:experiments:list` | List all Remote Config experiments in the active Firebase project. This command supports the following optional flags: - `--filter EXPRESSION` Specify the expression to filter the experiments. - `--pageSize NUMBER` Specify the number of experiments to return per page. If omitted, defaults to `10`. - `--pageToken TOKEN` Specify the starting offset for the list. |
| `remoteconfig:experiments:get \ EXPERIMENT_ID` | Retrieve the details of the specified Remote Config experiment. The table output includes the experiment's resource name, display name, state (`PENDING`, `RUNNING`, `DONE`, or `EXPIRED`), start and end times, variants (names and traffic allocation weights), and configured objectives/metrics. The experiment description is only included in raw JSON output when `--json` is passed. |
| `remoteconfig:experiments:delete \ EXPERIMENT_ID` | Delete the specified Remote Config experiment. The CLI displays a confirmation prompt before taking action and doesn't support a `-f` or `--force` flag. In non-interactive mode, confirmation defaults to no and the command exits without deleting the experiment. |
| `remoteconfig:rollouts:list` | List all Remote Config rollouts in the active Firebase project. This command supports the following optional flags: - `--filter EXPRESSION` Specify the expression to filter the rollouts. - `--pageSize NUMBER` Specify the number of rollouts to return per page. If omitted, defaults to `10`. - `--pageToken TOKEN` Specify the starting offset for the list. |
| `remoteconfig:rollouts:get \ ROLLOUT_ID` | Retrieve the details of the specified Remote Config rollout. |
| `remoteconfig:rollouts:delete \ ROLLOUT_ID` | Delete the specified Remote Config rollout. The CLI displays a confirmation prompt before taking action and doesn't support a `-f` or `--force` flag. (In non-interactive mode, confirmation defaults to no and the command exits without deleting the rollout.) |

### SQL Connect commands

These commands and their use cases are covered in more detail in the
[SQL Connect CLI reference guide](https://firebase.google.com/docs/sql-connect/cli-reference.md.txt).

| Command | Description |
|---|---|
| `dataconnect:services:list` | List all deployed SQL Connect services in the active Firebase project. |
| `dataconnect:sql:diff` | Display the differences between a local SQL Connect schema and your Cloud SQL database schema. This command supports the following optional flags: - `--service SERVICE_ID` Specify the SQL Connect service ID. If omitted, uses the single service configured in `firebase.json`. If multiple services are configured, the command fails unless you specify `--service` and, if needed, `--location`. - `--location LOCATION` Specify the location of the SQL Connect service. Only needed if the service ID is used in multiple locations. |
| `dataconnect:sql:migrate` | Migrate the schema for your Cloud SQL database to match your local SQL Connect schema. This command supports the following optional flags: - `--service SERVICE_ID` Specify the SQL Connect service ID. If omitted, uses the single service configured in `firebase.json` (if multiple services are configured, the command fails unless you specify `--service` and, if needed, `--location`). - `--location LOCATION` Specify the location of the SQL Connect service. Only needed if the service ID is used in multiple locations. In interactive mode, the CLI displays a confirmation prompt before taking action. In non-interactive mode, non-destructive migrations run automatically, while destructive changes abort unless you pass `-f` or `--force` (which also skips confirmation prompts in interactive mode). |
| `dataconnect:sql:grant \ --role SQL_ROLE \ --email EMAIL_ADDRESS` | Grant the specified <var translate="no">SQL_ROLE</var> (one of: `owner`, `writer`, or `reader`) to the specified <var translate="no">EMAIL_ADDRESS</var> of the user or service account. This command supports the following optional flags: - `--service SERVICE_ID` Specify the SQL Connect service ID. If omitted, uses the single service configured in `firebase.json` (if multiple services are configured, the command fails unless you specify `--service` and, if needed, `--location`). - `--location LOCATION` Specify the location of the SQL Connect service. Only needed if the service ID is used in multiple locations. |
| `dataconnect:sdk:generate` | Generate typed SDKs for your SQL Connect connectors. This command supports the following optional flags: - `--service SERVICE_ID` Specify the SQL Connect service ID. If omitted, generates SDKs for all configured services. - `--location LOCATION` Specify the location of the SQL Connect service. Only needed if the service ID is used in multiple locations. - `--watch` Watch for changes to your connector GQL files and regenerate your SDKs when updates occur. |