firebase-tools

14.2.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.2.1102,493latest
13.0.0-canary.07canary

Version History

VersionDownloads (Last 7 Days)Published
14.2.1102,493
14.2.0138,445
14.1.014,922
14.0.13,507
14.0.0143
13.35.153,846
13.35.0934
13.34.012,432
13.33.04,025
13.32.03,595
13.31.25,312
13.31.15,009
13.31.0293
13.30.07,105
13.29.32,029
13.29.29,700
13.29.111,928
13.29.0909
13.28.03,076
13.27.08,420
13.26.01,899
13.25.01,511
13.24.2792
13.24.1941
13.24.0524
13.23.1802
13.23.04,524
13.22.11,676
13.22.01,709
13.21.022
13.20.21,543
13.20.1508
13.20.0262
13.19.0355
13.18.01,462
13.17.02,129
13.16.03,236
13.15.41,954
13.15.397
13.15.24,687
13.15.11,036
13.15.01,944
13.14.2398
13.14.1144
13.14.0113
13.13.3744
13.13.2238
13.13.1240
13.13.01,835
13.12.0993
13.11.4345
13.11.3650
13.11.21,774
13.11.1149
13.11.0116
13.10.21,995
13.10.11,472
13.10.0184
13.9.01,391
13.8.31,156
13.8.212
13.8.1324
13.8.011,189
13.7.5232
13.7.44,117
13.7.31,459
13.7.2576
13.7.1233
13.7.01,004
13.6.11,086
13.6.05,655
13.5.2192
13.5.1478
13.5.058
13.4.1309
13.4.0942
13.3.11,676
13.3.01,214
13.2.1666
13.2.0137
13.1.0816
13.0.31,816
13.0.21,714
13.0.1303
13.0.01,127
13.0.0-canary.07
12.9.120,079
12.9.02,995
12.8.11,402
12.8.0301
12.7.01,141
12.6.2340
12.6.1381
12.6.029
12.5.4483
12.5.3191
12.5.21,621
12.5.120
12.5.015
12.4.8227
12.4.7416
12.4.6604
12.4.5248
12.4.4448
12.4.3673
12.4.2265
12.4.11,285
12.4.0362
12.3.1305
12.3.0603
12.2.163
12.2.011
12.1.037
12.0.136
12.0.0909
11.30.010,929
11.29.1619
11.29.01,228
11.28.0655
11.27.078
11.26.069
11.25.323
11.25.271
11.25.1199
11.25.06
11.24.1793
11.24.0690
11.23.1537
11.23.017
11.22.0302
11.21.0132
11.20.0191
11.19.04,675
11.18.0410
11.17.0329
11.16.12,146
11.16.0447
11.15.0142
11.14.410
11.14.36
11.14.3-canary.00
11.14.2359
11.14.173
11.14.015
11.13.0531
11.12.1-canary.02
11.12.025
11.11.1-canary.01
11.11.0602
11.10.1-canary.20
11.10.1-canary.10
11.10.1-canary.03
11.10.0473
11.9.0709
11.8.116
11.8.0178
11.7.06
11.6.048
11.5.020
11.4.211
11.4.142
11.4.051
11.3.0337
11.2.242
11.2.151
11.2.030
11.1.0116
11.0.1171
11.0.048
10.9.22,628
10.9.17
10.9.015
10.8.017
10.7.237
10.7.120
10.7.013
10.6.0157
10.5.0211
10.4.2673
10.4.11
10.4.037
10.3.13
10.3.04
10.2.2792
10.2.1119
10.2.019
10.1.5150
10.1.466
10.1.31
10.1.264
10.1.15
10.1.022
9.23.39,014
10.0.1491
10.0.0117
9.23.2148
9.23.1222
9.23.0284
9.22.0253
9.21.088
9.20.091
9.19.057
9.18.0233
9.17.085
9.16.6258
9.16.5161
9.16.44
9.16.324
9.16.26
9.16.13
9.16.0545
9.15.13
9.15.03
9.14.0217
9.13.131
9.13.056
9.12.1138
9.12.067
9.11.069
9.10.2113
9.10.15
9.10.0695
9.9.0277
9.8.0172
9.7.05
9.6.11,267
9.6.015
9.5.0284
9.4.025
9.3.0673
9.2.2146
9.2.1531
9.2.012
9.1.218
9.1.13
9.1.0180
9.0.1275
9.0.0365
8.20.03,404
8.19.0147
8.18.128
8.18.019
8.17.047
8.16.2244
8.16.116
8.16.07
8.15.159
8.15.0153
8.14.177
8.14.013
8.13.145
8.13.018
8.12.1111
8.12.093
8.11.278
8.11.16
8.11.045
8.10.0171
8.9.2180
8.9.15
8.9.050
8.8.1158
8.8.01
8.7.0154
8.6.062
8.5.0155
8.4.3114
8.4.244
8.4.139
8.4.016
8.3.011
8.2.053
8.1.141
8.1.016
8.0.312
8.0.243
8.0.120
8.0.0165
7.16.23,225
7.16.166
7.16.06
7.15.150
7.15.025
7.14.0339
7.13.128
7.13.079
7.12.1229
7.12.04
7.11.0122
7.10.01
7.9.05
7.8.133
7.8.01
7.7.0523
7.6.212
7.6.138
7.6.010
7.5.017
7.4.097
7.3.220
7.3.14
7.3.09
7.2.461
7.2.33
7.2.211
7.2.125
7.2.03
7.1.14
7.1.012
7.0.214
7.0.122
7.0.010
6.12.0621
6.11.018
6.10.031
6.9.210
6.9.13
6.9.09
6.8.018
6.7.25
6.7.1171
6.7.02
6.6.06
6.5.37
6.5.23
6.5.13
6.5.020
6.4.072
6.3.123
6.3.021
6.2.221
6.2.13
6.2.06
6.1.213
6.1.127
6.1.034
6.0.19
6.0.011
5.1.1130
5.1.01
5.0.16
5.0.01
4.2.1278
4.2.05
4.1.21
4.1.14
4.1.07
4.0.37
4.0.22
4.0.11
4.0.06
3.19.3149
3.19.214
3.19.11
3.19.06
3.18.628
3.18.54
3.18.420
3.18.33
3.18.216
3.18.11
3.18.09
3.17.71
3.17.65
3.17.52
3.17.426
3.17.35
3.17.25
3.17.12
3.17.04
3.16.027
3.15.41
3.15.33
3.15.24
3.15.11
3.15.02
3.14.08
3.13.118
3.13.01
3.12.023
3.11.04
3.10.16
3.10.06
3.9.216
3.9.137
3.9.015
3.8.05
3.7.09
3.6.12
3.6.04
3.5.02
3.4.01
3.3.01
3.2.31
3.2.22
3.2.13
3.2.01
3.1.01
3.0.82
3.0.75
3.0.62
3.0.52
3.0.41
3.0.33
3.0.22
3.0.11
3.0.01
2.2.154
2.2.01
2.1.12
2.1.01
2.0.24
2.0.14
2.0.03
1.2.0194
1.1.64
1.1.53
1.1.43
1.1.35
1.1.24
1.1.14
1.1.03
1.0.64
1.0.55
1.0.43
1.0.34
1.0.23
1.0.13
1.0.03
0.5.01
0.4.03
0.3.03
0.2.03
0.1.651
0.1.53
0.1.43
0.1.33
0.1.23
0.1.14
0.1.05
0.0.63
0.0.53
0.0.43
0.0.30
0.0.24
0.0.11

Package Sidebar

Install

npm i firebase-tools

Weekly Downloads

573,737

Version

14.2.1

License

MIT

Unpacked Size

3.67 MB

Total Files

722

Last publish

Collaborators

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