firebase-tools

14.3.1 • Public • Published

Firebase CLI Actions Status Node Version NPM version

The Firebase Command Line Interface (CLI) Tools can be used to test, manage, and deploy your Firebase project from the command line.

  • Deploy code and assets to your Firebase projects
  • Run a local web server for your Firebase Hosting site
  • Interact with data in your Firebase database
  • Import/Export users into/from Firebase Auth

To get started with the Firebase CLI, read the full list of commands below or check out the documentation.

Installation

Node Package

You can install the Firebase CLI using npm (the Node Package Manager). Note that you will need to install Node.js and npm. Installing Node.js should install npm as well.

To download and install the Firebase CLI run the following command:

npm install -g firebase-tools

This will provide you with the globally accessible firebase command.

Standalone Binary

The standalone binary distribution of the Firebase CLI allows you to download a firebase executable without any dependencies.

To download and install the CLI run the following command:

curl -sL firebase.tools | bash

Commands

The command firebase --help lists the available commands and firebase <command> --help shows more details for an individual command.

If a command is project-specific, you must either be inside a project directory with an active project alias or specify the Firebase project id with the -P <project_id> flag.

Below is a brief list of the available commands and their function:

Configuration Commands

Command Description
login Authenticate to your Firebase account. Requires access to a web browser.
logout Sign out of the Firebase CLI.
login:ci Generate an authentication token for use in non-interactive environments.
login:add Authorize the CLI for an additional account.
login:list List authorized CLI accounts.
login:use Set the default account to use for this project
use Set active Firebase project, manage project aliases.
open Quickly open a browser to relevant project resources.
init Setup a new Firebase project in the current directory. This command will create a firebase.json configuration file in your current directory.
help Display help information about the CLI or specific commands.

Append --no-localhost to login (i.e., firebase login --no-localhost) to copy and paste code instead of starting a local server for authentication. A use case might be if you SSH into an instance somewhere and you need to authenticate to Firebase on that machine.

Project Management Commands

Command Description
apps:create Create a new Firebase app in a project.
apps:list List the registered apps of a Firebase project.
apps:sdkconfig Print the configuration of a Firebase app.
projects:addfirebase Add Firebase resources to a Google Cloud Platform project.
projects:create Create a new Firebase project.
projects:list Print a list of all of your Firebase projects.

Deployment and Local Emulation

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

Command Description
emulators:exec Start the local Firebase emulators, run a test script, then shut down the emulators.
emulators:start Start the local Firebase emulators.
deploy Deploys your Firebase project. Relies on firebase.json configuration and your local project folder.
serve Start a local server with your Firebase Hosting configuration and HTTPS-triggered Cloud Functions. Relies on firebase.json.
setup:emulators:database Downloads the database emulator.
setup:emulators:firestore Downloads the firestore emulator.

App Distribution Commands

Command Description
appdistribution:distribute Upload a distribution.

Auth Commands

Command Description
auth:import Batch importing accounts into Firebase from data file.
auth:export Batch exporting accounts from Firebase into data file.

Detailed doc is here.

Realtime Database Commands

Command Description
database:get Fetch data from the current project's database and display it as JSON. Supports querying on indexed data.
database:set Replace all data at a specified location in the current project's database. Takes input from file, STDIN, or command-line argument.
database:push Push new data to a list at a specified location in the current project's database. Takes input from file, STDIN, or command-line argument.
database:remove Delete all data at a specified location in the current project's database.
database:update Perform a partial update at a specified location in the current project's database. Takes input from file, STDIN, or command-line argument.
database:profile Profile database usage and generate a report.
database:instances:create Create a realtime database instance.
database:instances:list List realtime database instances.
database:settings:get Read the realtime database setting at path
database:settings:set Set the realtime database setting at path.

Extensions Commands

Command Description
ext Display information on how to use ext commands and extensions installed to your project.
ext:configure Configure an existing extension instance.
ext:info Display information about an extension by name (extensionName@x.y.z for a specific version)
ext:install Install an extension.
ext:sdk:install Install and SDK for an extension so you can define the extension in a functions codebase.
ext:list List all the extensions that are installed in your Firebase project.
ext:uninstall Uninstall an extension that is installed in your Firebase project by Instance ID.
ext:update Update an existing extension instance to the latest version.

Cloud Firestore Commands

Command Description
firestore:delete Delete documents or collections from the current project's database. Supports recursive deletion of subcollections.
firestore:indexes List all deployed indexes from the current project.

Cloud Functions Commands

Command Description
functions:log Read logs from deployed Cloud Functions.
functions:list List all deployed functions in your Firebase project.
functions:config:set Store runtime configuration values for the current project's Cloud Functions.
functions:config:get Retrieve existing configuration values for the current project's Cloud Functions.
functions:config:unset Remove values from the current project's runtime configuration.
functions:config:clone Copy runtime configuration from one project environment to another.
functions:secrets:set Create or update a secret for use in Cloud Functions for Firebase.
functions:secrets:get Get metadata for secret and its versions.
functions:secrets:access Access secret value given secret and its version. Defaults to accessing the latest version.
functions:secrets:prune Destroys unused secrets.
functions:secrets:destroy Destroy a secret. Defaults to destroying the latest version.
functions:delete Delete one or more Cloud Functions by name or group name.
functions:shell Locally emulate functions and start Node.js shell where these local functions can be invoked with test data.

Hosting Commands

Command Description
hosting:disable Stop serving Firebase Hosting traffic for the active project. A "Site Not Found" message will be displayed at your project's Hosting URL after running this command.

Remote Config Commands

Command Description
remoteconfig:get Get a Firebase project's Remote Config template.
remoteconfig:versions:list Get a list of the most recent Firebase Remote Config template versions that have been published.
remoteconfig:rollback Roll back a project's published Remote Config template to the version provided by --version_number flag.

Use firebase:deploy --only remoteconfig to update and publish a project's Firebase Remote Config template.

Authentication

General

The Firebase CLI can use one of four authentication methods listed in descending priority:

  • User Token - DEPRECATED: this authentication method will be removed in a future major version of firebase-tools; use a service account to authenticate instead - provide an explicit long-lived Firebase user token generated from firebase login:ci. Note that these tokens are extremely sensitive long-lived credentials and are not the right option for most cases. Consider using service account authorization instead. The token can be set in one of two ways:
    • Set the --token flag on any command, for example firebase --token="<token>" projects:list.
    • Set the FIREBASE_TOKEN environment variable.
  • Local Login - run firebase login to log in to the CLI directly as yourself. The CLI will cache an authorized user credential on your machine.
  • Service Account - set the GOOGLE_APPLICATION_CREDENTIALS environment variable to point to the path of a JSON service account key file. For more details, see Google Cloud's Getting started with authentication guide.
  • Application Default Credentials - if you use the gcloud CLI and log in with gcloud auth application-default login, the Firebase CLI will use them if none of the above credentials are present.

Multiple Accounts

By default firebase login sets a single global account for use on all projects. If you have multiple Google accounts which you use for Firebase projects you can authorize multiple accounts and use them on a per-project or per-command basis.

To authorize an additonal account for use with the CLI, run firebase login:add. You can view the list of authorized accounts with firebase login:list.

To set the default account for a specific Firebase project directory, run firebase login:use from within the directory and select the desired account. To check the default account for a directory, run firebase login:list and the default account for the current context will be listed first.

To set the account for a specific command invocation, use the --account flag with any command. For example firebase --account=user@domain.com deploy. The specified account must have already been added to the Firebase CLI using firebase login:add.

Cloud Functions Emulator

The Cloud Functions emulator is exposed through commands like emulators:start, serve and functions:shell. Emulated Cloud Functions run as independent node processes on your development machine which means they have their own credential discovery mechanism.

By default these node processes are not able to discover credentials from firebase login. In order to provide a better development experience, when you are logged in to the CLI through firebase login we take the user credentials and construct a temporary credential that we pass into the emulator through GOOGLE_APPLICATION_CREDENTIALS. We only do this if you have not already set the GOOGLE_APPLICATION_CREDENTIALS environment variable yourself.

Using behind a proxy

The CLI supports HTTP(S) proxies via environment variables. To use a proxy, set the HTTPS_PROXY or HTTP_PROXY value in your environment to the URL of your proxy (e.g. HTTP_PROXY=http://127.0.0.1:12345).

Using with CI Systems

The Firebase CLI requires a browser to complete authentication, but is fully compatible with CI and other headless environments.

Complete the following steps to run Firebase commands in a CI environment. Find detailed instructions for each step in Google Cloud's Getting started with authentication guide.

  1. Create a service account and grant it the appropriate level of access to your project.
  2. Create a service account key (JSON file) for that service account.
  3. Store the key file in a secure, accessible way in your CI system.
  4. Set GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json in your CI system when running Firebase commands.

To disable access for the service account, find the service account for your project in the Google Cloud Console, and then either remove the key, or disable or delete the service account.

Using as a Module

The Firebase CLI can also be used programmatically as a standard Node module. Each command is exposed as a function that takes positional arguments followed by an options object and returns a Promise.

So if we run this command at our command line:

$ firebase --project="foo" apps:list ANDROID

That translates to the following in Node:

const client = require("firebase-tools");
client.apps
  .list("ANDROID", { project: "foo" })
  .then((data) => {
    // ...
  })
  .catch((err) => {
    // ...
  });

The options object must be the very last argument and any unspecified positional argument will get the default value of "". The following two invocations are equivalent:

const client = require("firebase-tools");

// #1 - No arguments or options, defaults will be inferred
client.apps.list();

// #2 - Explicitly provide "" for all arguments and {} for options
client.apps.list("", {});

Note: when used in a limited environment like Cloud Functions, not all firebase-tools commands will work programatically because they require access to a local filesystem.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
14.3.141,703latest
13.0.0-canary.02canary

Version History

VersionDownloads (Last 7 Days)Published
14.3.141,703
14.3.077,070
14.2.2127,340
14.2.114,348
14.2.04,270
14.1.08,118
14.0.13,786
14.0.0103
13.35.165,651
13.35.01,001
13.34.010,131
13.33.03,971
13.32.03,841
13.31.26,073
13.31.13,483
13.31.0321
13.30.07,940
13.29.31,454
13.29.26,604
13.29.112,607
13.29.0617
13.28.02,894
13.27.010,834
13.26.02,525
13.25.01,493
13.24.2704
13.24.11,413
13.24.0451
13.23.1902
13.23.03,141
13.22.12,343
13.22.02,069
13.21.07
13.20.21,896
13.20.1288
13.20.0446
13.19.0423
13.18.02,180
13.17.01,911
13.16.02,203
13.15.41,111
13.15.3108
13.15.24,204
13.15.1987
13.15.01,928
13.14.2432
13.14.199
13.14.069
13.13.3958
13.13.2249
13.13.1208
13.13.01,016
13.12.0396
13.11.4172
13.11.3415
13.11.21,737
13.11.1144
13.11.033
13.10.21,910
13.10.11,930
13.10.0153
13.9.01,223
13.8.31,022
13.8.249
13.8.1328
13.8.01,368
13.7.5151
13.7.4892
13.7.31,206
13.7.2254
13.7.1230
13.7.01,221
13.6.1794
13.6.05,187
13.5.2214
13.5.1435
13.5.0137
13.4.1364
13.4.01,054
13.3.11,458
13.3.0933
13.2.1521
13.2.094
13.1.0882
13.0.31,316
13.0.21,497
13.0.1253
13.0.01,270
13.0.0-canary.02
12.9.120,589
12.9.01,036
12.8.11,180
12.8.0204
12.7.01,176
12.6.2202
12.6.1268
12.6.026
12.5.4433
12.5.331
12.5.21,339
12.5.118
12.5.033
12.4.8211
12.4.7754
12.4.6835
12.4.596
12.4.4393
12.4.3684
12.4.2168
12.4.1807
12.4.0372
12.3.1208
12.3.0621
12.2.160
12.2.022
12.1.050
12.0.136
12.0.0572
11.30.010,528
11.29.1525
11.29.01,627
11.28.0686
11.27.0119
11.26.077
11.25.3112
11.25.252
11.25.1150
11.25.020
11.24.1864
11.24.0983
11.23.1420
11.23.021
11.22.0222
11.21.0124
11.20.0351
11.19.06,233
11.18.0418
11.17.0295
11.16.12,213
11.16.0412
11.15.0121
11.14.419
11.14.38
11.14.3-canary.01
11.14.2167
11.14.1104
11.14.011
11.13.0477
11.12.1-canary.05
11.12.019
11.11.1-canary.01
11.11.0804
11.10.1-canary.21
11.10.1-canary.11
11.10.1-canary.03
11.10.0267
11.9.0767
11.8.110
11.8.0241
11.7.019
11.6.029
11.5.013
11.4.224
11.4.110
11.4.050
11.3.0265
11.2.232
11.2.191
11.2.024
11.1.0185
11.0.1134
11.0.043
10.9.22,922
10.9.18
10.9.011
10.8.023
10.7.234
10.7.124
10.7.027
10.6.0211
10.5.089
10.4.2679
10.4.16
10.4.043
10.3.19
10.3.07
10.2.2888
10.2.1211
10.2.022
10.1.5103
10.1.487
10.1.36
10.1.255
10.1.19
10.1.015
9.23.310,158
10.0.1567
10.0.0143
9.23.2119
9.23.1228
9.23.0403
9.22.0283
9.21.059
9.20.073
9.19.013
9.18.0134
9.17.047
9.16.6110
9.16.584
9.16.48
9.16.313
9.16.26
9.16.18
9.16.0743
9.15.16
9.15.06
9.14.057
9.13.128
9.13.039
9.12.148
9.12.053
9.11.037
9.10.2133
9.10.16
9.10.0665
9.9.0226
9.8.049
9.7.08
9.6.11,651
9.6.019
9.5.0295
9.4.043
9.3.0432
9.2.258
9.2.11,820
9.2.08
9.1.211
9.1.16
9.1.096
9.0.1277
9.0.0398
8.20.03,241
8.19.0145
8.18.137
8.18.07
8.17.020
8.16.276
8.16.17
8.16.016
8.15.133
8.15.053
8.14.128
8.14.07
8.13.19
8.13.018
8.12.194
8.12.089
8.11.220
8.11.19
8.11.017
8.10.058
8.9.264
8.9.16
8.9.014
8.8.139
8.8.06
8.7.0393
8.6.049
8.5.0336
8.4.3105
8.4.212
8.4.187
8.4.014
8.3.011
8.2.019
8.1.128
8.1.014
8.0.315
8.0.27
8.0.18
8.0.086
7.16.22,646
7.16.127
7.16.06
7.15.110
7.15.06
7.14.0292
7.13.16
7.13.024
7.12.191
7.12.06
7.11.0966
7.10.06
7.9.08
7.8.138
7.8.06
7.7.0523
7.6.26
7.6.19
7.6.010
7.5.025
7.4.075
7.3.29
7.3.16
7.3.07
7.2.435
7.2.38
7.2.212
7.2.129
7.2.06
7.1.18
7.1.016
7.0.212
7.0.18
7.0.07
6.12.0509
6.11.074
6.10.026
6.9.26
6.9.17
6.9.07
6.8.07
6.7.27
6.7.1175
6.7.06
6.6.021
6.5.37
6.5.28
6.5.16
6.5.017
6.4.042
6.3.17
6.3.07
6.2.214
6.2.16
6.2.06
6.1.26
6.1.110
6.1.028
6.0.18
6.0.013
5.1.188
5.1.08
5.0.18
5.0.06
4.2.1619
4.2.06
4.1.26
4.1.16
4.1.09
4.0.39
4.0.26
4.0.16
4.0.06
3.19.3137
3.19.26
3.19.18
3.19.07
3.18.66
3.18.59
3.18.48
3.18.37
3.18.230
3.18.16
3.18.08
3.17.77
3.17.66
3.17.59
3.17.46
3.17.36
3.17.29
3.17.16
3.17.08
3.16.0118
3.15.46
3.15.37
3.15.28
3.15.18
3.15.06
3.14.07
3.13.123
3.13.09
3.12.013
3.11.06
3.10.16
3.10.06
3.9.26
3.9.17
3.9.07
3.8.06
3.7.06
3.6.16
3.6.06
3.5.07
3.4.06
3.3.06
3.2.36
3.2.26
3.2.17
3.2.06
3.1.06
3.0.86
3.0.76
3.0.67
3.0.56
3.0.46
3.0.36
3.0.26
3.0.16
3.0.06
2.2.18
2.2.06
2.1.16
2.1.06
2.0.26
2.0.16
2.0.06
1.2.0167
1.1.68
1.1.56
1.1.46
1.1.36
1.1.26
1.1.110
1.1.06
1.0.610
1.0.56
1.0.46
1.0.36
1.0.26
1.0.17
1.0.06
0.5.06
0.4.06
0.3.06
0.2.06
0.1.648
0.1.58
0.1.46
0.1.36
0.1.29
0.1.17
0.1.07
0.0.615
0.0.57
0.0.47
0.0.30
0.0.28
0.0.17

Package Sidebar

Install

npm i firebase-tools

Weekly Downloads

582,339

Version

14.3.1

License

MIT

Unpacked Size

3.72 MB

Total Files

764

Last publish

Collaborators

  • firebase-ops
  • feiyang.chen
  • google-wombot
  • chholland