Firebase CLI reference Stay organized with collections Save and categorize content based on your preferences.
TheFirebase CLI(GitHub) provides avariety of tools for managing, viewing, and deploying to Firebase projects.
Before using theFirebase CLI,set up a Firebase project.
Set up or update the CLI
Install theFirebase CLI
You can install theFirebase CLI using a method that matches your operatingsystem, experience level, and/or use case. Regardless of how you install theCLI, you have access to the same functionality and thefirebase command.
Windows
You can install theFirebase CLI for Windows using one of the followingoptions:
| 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 thefirebase command. | New developers Developers not using or unfamiliar withNode.js |
| npm | Use npm (the Node Package Manager) to install the CLI and enable the globally availablefirebase command. | Developers usingNode.js |
standalone binary
To download and run the binary for theFirebase CLI, follow these steps:
Download theFirebase CLI binary forWindows.
Access the binary to open a shell where you can run the
firebasecommand.Continue tolog in and test the CLI.
npm
To usenpm (the Node Package Manager) to install theFirebase CLI, follow these steps:
InstallNode.js usingnvm-windows (the Node Version Manager). Installing Node.js automatically installsthe
Note: TheFirebase CLI requiresNode.js v18.0.0 or later. SomeFirebase features might require specific versions of Node.js, so checkeach Firebase product's getting started page for any specific Node.jsrequirements.npmcommand tools.Install theFirebase CLI via
npmby running the following command:npm install -g firebase-tools
This command enables the globally available
Note: If thefirebasecommand.npm install -g firebase-toolscommand fails, you mightneed tochange npm permissions.Continue tolog in and test the CLI.
macOS or Linux
You can install theFirebase CLI for macOS or Linux using one of thefollowing 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 availablefirebase command. | New developers Developers not using or unfamiliar withNode.js Automated deploys in aCI/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 availablefirebase command. | Developers usingNode.js |
auto install script
To install theFirebase CLI using the automatic install script, followthese steps:
Run the following cURL command:
curl -sL https://firebase.tools | bash
This script automatically detects your operating system, downloads thelatestFirebase CLI release, then enables the globally available
Note: If you experience permission issues when installing on MacOS orLinux, you might need to usefirebasecommand.sudoto grant the script the requiredpermissions:sudo curl -sL https://firebase.tools | bashContinue tolog in and test the CLI.
For more examples and details about the automatic install script, refer tothe script's source code atfirebase.tools.
standalone binary
To download and run the binary for theFirebase CLI that's specificfor your OS, follow these steps:
(Optional) Set up the globally available
firebasecommand.- Make the binary executable by running
chmod +x ./firebase_tools. - Add the binary's path to your PATH.
firebasecommand, you'll need toaccess the binary each time you want to run aFirebase CLI command.- Make the binary executable by running
Continue tolog in and test the CLI.
npm
To usenpm (the Node Package Manager) to install theFirebase CLI,follow these steps:
InstallNode.js usingnvm (the Node Version Manager).
Note: TheFirebase CLI requiresNode.js v18.0.0 or later. SomeFirebase features might require specific versions of Node.js, so checkeach Firebase product's getting started page for any specific Node.jsrequirements.
Installing Node.js automatically installsthenpmcommand tools.Install theFirebase CLI via
npmby running the following command:npm install -g firebase-tools
This command enables the globally available
Note: If thefirebasecommand.npm install -g firebase-toolscommand fails, you mightneed tochange npm permissions.Continue tolog in and test the CLI.
Log in and test theFirebase CLI
After installing the CLI, you must authenticate. Then you can confirmauthentication by listing your Firebase projects.
Log into Firebase using your Google account by running the followingcommand:
firebase login
This command connects your local machine to Firebase and grants youaccess to your Firebase projects.
Note: Thefirebase logincommand opens a web page that connects tolocalhoston your machine. If you're using a remote machine and don't haveaccess tolocalhost, run the command with the flag--no-localhost.Note: You can alsouse theFirebase CLI with CI systems.Test that the CLI is properly installed and accessing your account bylisting your Firebase projects. Run the following command:
firebase projects:list
The displayed list should be the same as the Firebase projects listed intheFirebase console.
Update to the latest CLI version
Generally, you want to use the most up-to-dateFirebase CLI version.
In many cases, new features and bug fixes are available only with the latest version of theFirebase 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 youinstalled the CLI.
Windows
- standalone binary:Download the newversion,then replace it on your system
- npm: Run
npm install -g firebase-tools
macOS
automatic install script: Run
Note: If you experience permission issues when installing on MacOS orLinux, you might need to usecurl -sL https://firebase.tools | upgrade=true bashsudoto grant the script the requiredpermissions:sudo curl -sL https://firebase.tools | upgrade=true bashstandalone binary:Download the newversion, thenreplace it on your system
npm: Run
npm install -g firebase-tools
Linux
automatic install script: Run
Note: If you experience permission issues when installing on MacOS orLinux, you might need to usecurl -sL https://firebase.tools | upgrade=true bashsudoto grant the script the requiredpermissions:sudo curl -sL https://firebase.tools | upgrade=true bashstandalone binary:Download the newversion, thenreplace it on your system
npm: Run
npm install -g firebase-tools
Uninstall theFirebase CLI
How you uninstall the CLI depends on your operating system and how youinstalled the CLI.
Windows
- standalone binary: Delete the
firebase.exebinary that you downloaded. - npm: Run
npm uninstall -g firebase-tools
macOS
automatic install script: Run
Note: If you experience permission issues when uninstalling on MacOS orLinux, you might need to usecurl -sL https://firebase.tools | uninstall=true bashsudoto grant the script the requiredpermissions:sudo curl -sL https://firebase.tools | uninstall=true bashstandalone binary: Delete the
firebasebinary that you downloaded.If you added its location to yourPATHenvironment variable, be sure toremove it.npm: Run
npm uninstall -g firebase-tools
Linux
automatic install script: Run
Note: If you experience permission issues when uninstalling on MacOS orLinux, you might need to usecurl -sL https://firebase.tools | uninstall=true bashsudoto grant the script the requiredpermissions:sudo curl -sL https://firebase.tools | uninstall=true bashstandalone binary: Delete the
firebasebinary that you downloaded.If you added its location to yourPATHenvironment variable, be sure toremove it.npm: Run
npm uninstall -g firebase-tools
Use the CLI with CI systems
We recommend that you authenticate using Application Default Credentials whenusing the CLI with CI systems.
(Recommended) Use Application Default Credentials
TheFirebase CLI will detect and use Application Default Credentials ifthey're set. The simplest way to authenticate the CLI in CI and otherheadless environments is toset up Application Default Credentials.
(Legacy) UseFIREBASE_TOKEN
Alternatively, you can authenticate usingFIREBASE_TOKEN. This is less securethan Application Default Credentials and is no longer recommended.
On a machine with a browser,install theFirebase CLI.
Start the signin process by running the following command:
firebase login:ci
Visit the URL provided, then log in using a Google account.
Print a newrefresh token.The current CLI session will not be affected.
Store the output token in a secure but accessible way in your CI system.
Use this token when running
firebasecommands. You can use either of thefollowing two options:Option 1: Store the token as the environment variable
FIREBASE_TOKEN. Your system will automatically use the token.Option 2: Run all
firebasecommands with the--tokenTOKENflag in your CI system.
This is the order of precedence for token loading: flag, environmentvariable, desired Firebase project.
firebase logout --tokenTOKENInitialize a Firebase project
Many common tasks performed using the CLI, such as deploying to a Firebaseproject, require aproject directory. You establish a project directoryusing thefirebase init command. A project directory is usually the samedirectory as your source control root, and after runningfirebase init, thedirectory contains afirebase.json configurationfile.
To initialize a new Firebase project, run the following command from within yourapp's directory:
firebase init
firebase init command does not create a new directory. If you'restarting a new app, you must first make a directory, then runfirebase initfrom within that directory.Thefirebase init command steps you through setting up your project directoryand some Firebase products. During project initialization, theFirebase CLIasks you to complete the following tasks:
Select a default Firebase project.
This step associates the current project directory with a Firebase project sothat project-specific commands (like
firebase deploy) run against theappropriate Firebase project.It's also possible toassociate multiple Firebase projects(such as a staging project and a production project) with the same projectdirectory.
Select desired Firebase products to set up in your Firebase project.
This step prompts you to set configurations for specific files for theselected products. For more details on these configurations, refer to thespecific product's documentation (for example,Hosting). Note that youcan always run
firebase initlater to set up more Firebase products.
At the end of initialization, Firebase automatically creates the following twofiles at the root of your local app directory:
A
firebase.jsonconfiguration file that listsyour project configuration.A
.firebasercfile that stores your projectaliases.
Thefirebase.json file
Thefirebase init command creates afirebase.json configuration file in the root of your project directory.
Thefirebase.json file is required todeploy assets with theFirebase CLI because it specifieswhich files and settings from your project directory are deployed to yourFirebase project. Since some settings can be defined in either your projectdirectory or theFirebase console, make sure that you resolve any potentialdeployment conflicts.
You canconfigure mostFirebase Hosting optionsdirectly in thefirebase.json file. However, for otherFirebase services that can be deployed with theFirebase CLI,thefirebase init command creates specific files where you can define settingsfor those services, such as anindex.js file forCloud Functions. You canalso set uppredeploy or postdeploy hooks in thefirebase.json file.
firebase init again for any Firebase service, the commandwill overwrite the corresponding section of thefirebase.json file back to thedefault configuration for that service.The following is an examplefirebase.json file with default settings if youselectFirebase Hosting,Cloud Firestore, andCloud Functions for Firebase(with TypeScript source and lint options selected) during initialization.
{ "hosting": { "public": "public", "ignore": [ "firebase.json", "**/.*", "**/node_modules/**" ] }, "firestore": { "rules": "firestore.rules", "indexes": "firestore.indexes.json" }, "functions": { "predeploy": [ "npm --prefix \"$RESOURCE_DIR\" run lint", "npm --prefix \"$RESOURCE_DIR\" run build" ] }}Whilefirebase.json is used by default, you can pass the--configPATH flag to specify an alternateconfiguration file.
Configuration for multipleCloud Firestore databases
When you runfirebase init, yourfirebase.json file will contain a singlefirestore key corresponding to your project's default database, as shownabove.
If your project contains multipleCloud Firestore databases, edit yourfirebase.json file to associate differentCloud Firestore Security Rules and database index source files with each database. Modify the file with aJSON array, with one entry for each database.
"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 specifiesa list of files in thefunctions directory to ignore. Thisprevents deploying to the backend extraneous files that couldincrease 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 forignore infirebase.json, makesure that you keep (or add, if it is missing) the list of files shown above.
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 anotherfor production. By using different project environments, you can verify changesbefore deploying to production. Thefirebase use command allows you to switchbetween aliases as well as create new aliases.
Add a project alias
When you select a Firebase project duringprojectinitialization, the project is automaticallyassigned the alias ofdefault. However, to allow project-specific commands torun against a different Firebase project but still use thesame projectdirectory, run the following command from within your project directory:
firebase use --add
This command prompts you to select another Firebase project and assign theproject as alias. Alias assignments are written to a.firebaserc file insideyour project directory.
Use project aliases
To use assigned Firebase project aliases, run any of the following commands fromwithin your project directory.
| Command | Description |
|---|---|
firebase use | View a list of currently defined aliases for your project directory |
firebase use \ | Directs all commands to run against the specified Firebase project. The CLI uses this project as the currently "active project". |
firebase use --clear | Clears the active project. Run |
firebase use \ | Removes an alias from your project directory. |
You can override what's being used as the currently active project by passingthe--project flag with any CLI command. As an example: You can set yourCLI to run against a Firebase project that you've assigned thestagingalias. If you want to run a single command against the Firebase project thatyou've assigned theprod alias, then you can run, for example,.
Source control and project aliases
In general, you should check your.firebaserc file into source control toallow your team to share project aliases. However, for open source projects orstarter 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 passthe--project flag with each command or runfirebase usePROJECT_ID without assigning an alias tothe Firebase project.
Serve and test your Firebase project locally
You can view and test your Firebase project on locally hosted URLs beforedeploying to production. If you only want to test select features, you can usea comma-separated list in a flag on thefirebase serve command.
Run the following command from the root of your local project directory if youwant to do either of the following tasks:
- View the static content for your Firebase-hosted app.
- UseCloud Functions togenerate dynamic content forFirebase Hosting and you want to use yourproduction (deployed) HTTP functions to emulateHosting on a local URL.
firebase serve --only hosting
Emulate your project usinglocal HTTP functions
Run any of the following commands from your project directory to emulate yourproject usinglocal HTTP functions.
To emulate HTTP functions and hosting for testing on local URLs, use eitherof 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 fromlocalhost. Thismeans that you'll be able to access your hosted content from your computer's webbrowser but not from other devices on your network. If you'd like to test fromother 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
TheFirebase CLI manages deployment of code and assets to your Firebaseproject, including:
- New releases of yourFirebase Hosting sites
- New, updated, or existingCloud Functions for Firebase
- New or updated schemas and connectors forFirebase Data Connect
- Rules forFirebase Realtime Database
- Rules forCloud Storage for Firebase
- Rules forCloud Firestore
- Indexes forCloud Firestore
To deploy to a Firebase project, run the following command from your projectdirectory:
firebase deploy
You can optionally add a comment to each of your deployments. This comment willdisplay with the other deployment information on your project'sFirebase Hostingpage. For example:
firebase deploy -m "Deploying the best new feature ever."
When you use thefirebase deploy command, be aware of the following:
To deploy resources from a project directory, the project directorymust have a
firebase.jsonfile. This file isautomatically created for you by thefirebase initcommand.By default,
firebase deploycreates a release forall deployable resourcesin your project directory. To deploy specific Firebase services or features,use partial deployment.
Deployment conflicts for security rules
ForFirebase Realtime Database,Cloud Storage for Firebase, andCloud Firestore,you can define security rules either in your local project directory or in theFirebase console.
Note:When youdeploy security rules using theFirebase CLI,the rules defined in your project directory overwrite any existing rules in theFirebase console. So, if you choose to define or edit your security rulesusing theFirebase console, make sure that you also update the rules definedin your project directory.Another option to avoid deployment conflicts is touse partial deployment and only define rules in theFirebase console.
Deployment quotas
It's possible (though unlikely) that you might exceed a quota that limits therate or volume of your Firebase deployment operations. For example, whendeploying very large numbers of functions, you might receive anHTTP 429 Quotaerror message. To solve such issues, tryusing partial deployment.
Roll back a deployment
You can roll back aFirebase Hosting deployment from your project'sFirebase Hostingpage by selectingtheRollback action for the desired release.
It's not currently possible to roll back releases of security rules forFirebase Realtime Database,Cloud Storage for Firebase, orCloud Firestore.
Deploy specific Firebase services
If you only want to deploy specific Firebase services or features, you can use acomma-separated list in a flag on thefirebase deploy command. For example,the following command deploysFirebase Hosting content andCloud Storage security rules.
firebase deploy --only hosting,storage
The following table lists the services and features available for partialdeployment. The names in the flags correspond to the keys in yourfirebase.json configuration file.
| Flag syntax | Service or feature deployed |
|---|---|
--only hosting | Firebase Hosting content |
--only database | Firebase Realtime Database rules |
--only dataconnect | Firebase Data Connect schemas and connectors |
--only storage | Cloud Storage for Firebase rules |
--only firestore | Cloud Firestore rulesand indexes for all configured databases |
--only functions | Cloud Functions for Firebase (more specific versions of this flag are possible) |
--only rules syntax used by older versions of the CLI isdeprecated.Deploy specific functions
When deploying functions, you can target specific functions. For example:
firebase deploy --only functions:function1
firebase deploy --only functions:function1,functions:function2
Another option is to group functions into export groups in your/functions/index.js file. Grouping functions allows you to deploy multiplefunctions using a single command.
For example, you can write the following functions to define agroupA and agroupB:
varfunctions=require('firebase-functions/v1');exports.groupA={function1:functions.https.onRequest(...),function2:functions.database.ref('\path').onWrite(...)}exports.groupB=require('./groupB');In this example, a separatefunctions/groupB.js file contains additionalfunctions that specifically define the functions ingroupB. For example:
varfunctions=require('firebase-functions/v1');exports.function3=functions.storage.object().onChange(...);exports.function4=functions.analytics.event('in_app_purchase').onLog(...);In this example, you can deploy all thegroupA functions by running thefollowing command from your project directory:
firebase deploy --only functions:groupA
Or you can target a specific function within a group by running the followingcommand:
firebase deploy --only functions:groupA.function1,groupB.function4
Delete functions
TheFirebase CLI supports the following commands and options fordeleting previously deployed functions:
Deletes all functions that match the specified name in all regions:
firebase functions:deleteFUNCTION-1_NAME
Deletes a specified function running in a non-default region:
firebase functions:deleteFUNCTION-1_NAME --regionREGION_NAME
Deletes more than one function:
firebase functions:deleteFUNCTION-1_NAMEFUNCTION-2_NAME
Deletes a specified functions group:
firebase functions:deleteGROUP_NAME
Bypasses the confirmation prompt:
firebase functions:deleteFUNCTION-1_NAME --force
Set up predeploy and postdeploy scripted tasks
You can connect shell scripts to thefirebase deploy command to performpredeploy or postdeploy tasks. For example, a predeploy script couldtranspile TypeScript code into JavaScript, and a postdeploy hook could notifyadministrators of new site content deploys toFirebase Hosting.
To set up predeploy or postdeploy hooks, add bash scripts to yourfirebase.json configuration file. You can definebrief scripts directly in thefirebase.json file, or you can reference otherfiles that are in your project directory.
For example, the following script is thefirebase.json expression for apostdeploy task that sends a Slack message upon successful deployment toFirebase Hosting.
"hosting": { // ... "postdeploy": "./messageSlack.sh 'Just deployed toFirebase Hosting'", "public": "public"}ThemessageSlack.sh script file resides in the project directory and lookslike this:
curl -X POST -H 'Content-type: application/json' --data '{"text":"$1"}' \https://SLACK_WEBHOOK_URLYou can set uppredeploy andpostdeploy hooks for any of theassets that you can deploy. Note that runningfirebase deploytriggersall the predeploy and postdeploy tasks defined in yourfirebase.json file. To run only those tasks associated with a specificFirebase service,use partial deployment commands.
Bothpredeploy andpostdeploy hooks print the standard output and errorstreams 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 followingenvironment variables are available:
$GCLOUD_PROJECT: The active project's project ID$PROJECT_DIR: The root directory containing thefirebase.jsonfile$RESOURCE_DIR:(Forhostingandfunctionsscripts only) Thelocation of the directory that contains theHosting orCloud Functions resources to be deployed
Manage multipleRealtime Database instances
A Firebase project can havemultipleFirebase Realtime Database instances. Bydefault, CLI commands interact with yourdefault database instance.
However, you can interact with a non-default database instance by using the--instanceDATABASE_NAME--instance flag:
firebase database:getfirebase database:profilefirebase database:pushfirebase database:removefirebase database:setfirebase database:update
Command reference
CLI administrative commands
| Command | Description |
|---|---|
| help | Displays help information about the CLI or specific commands. |
| init | Associates and sets up a new Firebase project in the current directory. This command creates afirebase.json configuration file in the current directory. |
| login | Authenticates 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 |
| login:ci | Generates an authentication token for use in non-interactive environments. |
| logout | Signs out your Google Account from the CLI. |
| open | Opens a browser to relevant project resources. |
| projects:list | Lists all the Firebase projects to which you have access. |
| use | Sets the active Firebase project for the CLI. Managesproject aliases. |
Project management commands
| Command | Description | |
|---|---|---|
| Management of Firebase projects | ||
| projects:addfirebase | Adds Firebase resources to an existingGoogle Cloud project. | |
| projects:create | Creates a newGoogle Cloud project, then adds Firebase resources to the new project. | |
| projects:list | Lists all the Firebase projects to which you have access. | |
| Management of Firebase Apps (iOS, Android, Web) | ||
| apps:create | Creates a new Firebase App in the active project. | |
| apps:list | Lists the registered Firebase Apps in the active project. | |
| apps:sdkconfig | Prints the Google services configuration of a Firebase App. | |
| setup:web | Deprecated. Instead, useapps:sdkconfig and specifyweb as the platform argument.Prints the Google services configuration of a Firebase Web App. | |
| Management of SHA certificate hashes (Android only) | ||
| apps:android:sha:create \ FIREBASE_APP_IDSHA_HASH | Adds the specified SHA certificate hash to the specified Firebase Android App. | |
| apps:android:sha:delete \ FIREBASE_APP_IDSHA_HASH | Deletes the specified SHA certificate hash from the specified Firebase Android App. | |
| apps:android:sha:list \ FIREBASE_APP_ID | Lists the SHA certificate hashes for the specified Firebase Android App. | |
Deployment and local development
These commands let you deploy and interact with yourFirebase Hosting site.
| Command | Description |
|---|---|
| deploy | Deploys code and assets from your project directory to the active project. ForFirebase Hosting, afirebase.json configuration file is required. |
| serve | Starts a local web server with yourFirebase Hosting configuration. ForFirebase Hosting, afirebase.json configuration file is required. |
App Distribution commands
| Command | Description |
|---|---|
| appdistribution:distribute \ --appFIREBASE_APP_ID | Makes the build available to testers. |
| appdistribution:testers:add | Adds testers to the project. |
| appdistribution:testers:remove | Removes testers from the project. |
App Hosting commands
| Command | Description |
|---|---|
| apphosting:backends:create \ --projectPROJECT_ID \ --locationREGION --appAPP_ID | Creates the collection of managed resources linked to a single codebase that comprises anApp Hosting backend. Optionally specify an existing Firebase Web app by its Firebase app ID. |
| apphosting:backends:get \ BACKEND_ID \ --projectPROJECT_ID \ --locationREGION | Retrieves specific details, including the public URL, of a backend. |
| apphosting:backends:list \ --projectPROJECT_ID | Retrieves a list of all active backends associated with a project. |
| firebase apphosting:backends:delete \ BACKEND_ID \ --projectPROJECT_ID \ --locationREGION | Deletes a backend from the project. |
| firebase apphosting:config:export \ --projectPROJECT_ID \ --secretsENVIRONMENT_NAME | Exports secrets for use in app emulation. Defaults to secrets stored in apphosting.yaml, or takes--secrets to specify any environment that has a correspondingapphosting.ENVIRONMENT_NAME.yaml file. |
| firebase apphosting:rollouts:create \ BACKEND_ID \ --git_branchBRANCH_NAME \ --git_commitCOMMIT_ID | Creates a manually triggered rollout. Optionally specify the latest commit to a branch or a specific commit. If no options are provided, prompts selection from a list of branches. |
| apphosting:secrets:setKEY --projectPROJECT_ID \ --locationREGION \ --data-fileDATA_FILE_PATH | Stores secret material in Secret Manager. Optionally provide a file path from which to read secret data. Set to _ to read secret data from standard input. |
| apphosting:secrets:grantaccessKEYBACKEND_ID \ --projectPROJECT_ID \ --locationREGION | Grants thebackend service account access to the provided secret so that it can be accessed byApp Hosting at build or run time. |
| apphosting:secrets:describeKEY \ --projectPROJECT_ID | Gets the metadata for a secret and its versions. |
| firebase apphosting:secrets:access \ KEY[@version] \ --projectPROJECT_ID | Accesses a secret value given the secret and its version. Defaults to accessing the latest version. |
Authentication (user management) commands
| Command | Description |
|---|---|
| auth:export | Exports the active project's user accounts to a JSON or CSV file. For more details, refer to theauth:import and auth:export page. |
| auth:import | Imports the user accounts from a JSON or CSV file into the active project. For more details, refer to theauth:import and auth:export page. |
Cloud Firestore commands
| Command | Description |
|---|---|
| firestore:locations | List available locations for yourCloud Firestore database. |
| firestore:databases:createDATABASE_ID | Create a database instance in native mode in your Firebase project. The command takes the following flags:
|
| firestore:databases:list | List databases in your Firebase project. |
| firestore:databases:getDATABASE_ID | Get database configuration for a specified database in your Firebase project. |
| firestore:databases:updateDATABASE_ID | Update database configuration of a specified database in your Firebase project. At least one flag is required. The command takes the following flags:
|
| firestore:databases:deleteDATABASE_ID | Delete a database in your Firebase project. |
| firestore:indexes | List indexes for a database in your Firebase project. The command takes the following flag:
|
| firestore:delete | Deletes documents in the active project's database. Using the CLI, you can recursively delete all the documents in a collection. Note that deletingCloud Firestore data with the CLI incurs read and delete costs. For more information, seeUnderstandCloud Firestore billing. The command takes the following flag:
|
Cloud Functions for Firebase commands
| Command | Description |
|---|---|
| functions:config:clone | Clones another project's environment into the active Firebase project. |
| functions:config:get | Retrieves existing configuration values of the active project'sCloud Functions. |
| functions:config:set | Stores runtime configuration values of the active project'sCloud Functions. |
| functions:config:unset | Removes values from the active project's runtime configuration. |
| functions:log | Reads logs from deployedCloud Functions. |
For more information, refer to theenvironmentconfiguration documentation.
Crashlytics commands
| Command | Description |
|---|---|
| crashlytics:mappingfile:generateid \ --resource-file=PATH/TO/ANDROID_RESOURCE.XML | Generates 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 | Uploads a Proguard-compatible mapping (TXT) file for this app, and associates it with the mapping file ID declared in the specified Android resource (XML) file. |
| crashlytics:symbols:upload \ --app=FIREBASE_APP_ID \ PATH/TO/SYMBOLS | Generates aCrashlytics-compatible symbol file for native library crashes on Android and uploads it to Firebase servers. |
Data Connect commands
These commands and their use cases are covered in more detail in theData Connect CLI reference guide.
| Command | Description |
|---|---|
| dataconnect:services:list | Lists all deployedData Connect services in your Firebase project. |
| dataconnect:sql:diff \ SERVICE_ID | For the specified service, displays the differences between a localData Connect schema and your Cloud SQL database schema. |
| dataconnect:sql:migrate \ --force \ SERVICE_ID | Migrates your Cloud SQL database's schema to match your localData Connect schema. |
| dataconnect:sql:grant\ --role=ROLE \ --email=EMAIL \ SERVICE_ID | Grants the SQL role to the specified user or service account email. For the --role flag, the SQL role to grant is one of:owner,writer, orreader.For the --email flag, provide the email address of the user or service account to grant the role to. |
| dataconnect:sdk:generate | Generates typed SDKs for yourData Connect connectors. |
Extensions commands
| Command | Description |
|---|---|
| ext | Displays information on how to useFirebase Extensions commands. Lists the extension instances installed in the active project. |
| ext:configure \ EXTENSION_INSTANCE_ID | Reconfigures the parameter values of an extension instance in yourextension manifest. |
| ext:info \ PUBLISHER_ID/EXTENSION_ID | Prints detailed information about an extension. |
| ext:install \ PUBLISHER_ID/EXTENSION_ID | Adds a new instance of an extension into yourextension manifest. |
| ext:list | Lists all the extension instances installed in a Firebase project. Prints the instance ID for each extension. |
| ext:uninstall \ EXTENSION_INSTANCE_ID | Removes an extension instance from yourextension manifest. |
| ext:update \ EXTENSION_INSTANCE_ID | Updates an extension instance to the latest version in yourextension manifest. |
| ext:export | Exports all installed extension instances from your project to yourextension manifest. |
Extensions publisher commands
| Command | Description |
|---|---|
| ext:dev:init | Initializes a skeleton codebase for a new extension in the current directory. |
| ext:dev:list \ PUBLISHER_ID | Prints a list of all extensions uploaded by a publisher. |
| ext:dev:register | Registers a Firebase project as anextensions publisher project. |
| ext:dev:deprecate \ PUBLISHER_ID/EXTENSION_ID \ VERSION_PREDICATE | Deprecates 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 | Undeprecates 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, undeprecates all versions of that extension. |
| ext:dev:upload \ PUBLISHER_ID/EXTENSION_ID | Uploads a new version of an extension. |
| ext:dev:usage \ PUBLISHER_ID | Displays install counts and usage metrics for extensions uploaded by a publisher. |
Hosting commands
| Command | Description |
|---|---|
| hosting:disable | Stops servingFirebase Hosting traffic for the active Firebase project. Your project'sHosting URL will display a "Site Not Found" message after running this command. |
| Management ofHosting sites | |
| firebase hosting:sites:create \ SITE_ID | Creates a newHosting site in the active Firebase project using the specified (Optional) Specify an existing Firebase Web App to associate with the new site by passing the following flag: |
| firebase hosting:sites:delete \ SITE_ID | Deletes the specifiedHosting site The CLI displays a confirmation prompt before deleting the site. (Optional) Skip the confirmation prompt by passing the following flags: |
| firebase hosting:sites:get \ SITE_ID | Retrieves information about the specifiedHosting site |
| firebase hosting:sites:list | Lists allHosting sites for the active Firebase project |
| Management of preview channels | |
| firebase hosting:channel:create \ CHANNEL_ID | Creates a new preview channel in thedefaultHosting site using the specified This command does not deploy to the channel. |
| firebase hosting:channel:delete \ CHANNEL_ID | Deletes the specified preview channel You cannot delete a site's live channel. |
| firebase hosting:channel:deploy \ CHANNEL_ID | Deploys yourHosting content and config to the specified preview channel If the preview channel does not yet exist, this command creates the channel in thedefaultHosting site before deploying to the channel. |
| firebase hosting:channel:list | Lists all channels (including the "live" channel) in thedefaultHosting site |
| firebase hosting:channel:open \ CHANNEL_ID | Opens a browser to the specified channel's URL or returns the URL if opening in a browser isn't possible |
| Version cloning | |
| firebase hosting:clone \ SOURCE_SITE_ID:SOURCE_CHANNEL_ID \ TARGET_SITE_ID:TARGET_CHANNEL_ID | Clones 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 does not yet exist, this command creates a new preview channel in the "target"Hosting site before deploying to the channel. |
| firebase hosting:clone \ SOURCE_SITE_ID:@VERSION_ID \ TARGET_SITE_ID:TARGET_CHANNEL_ID | Clones the specified version to the specified "target" channel This command also deploys to the specified "target" channel. If the "target" channel does not yet exist, this command creates a new preview channel in the "target"Hosting site before deploying to the channel. You can find the |
Realtime Database commands
Note that you can create your initial, defaultRealtime Database instance in theFirebase console or by using thegeneralfirebase initworkflow or the specificfirebase init database flow.
Once instances are created, you can manage them as discussed inManage multipleRealtime Database instances.
| Command | Description |
|---|---|
| database:get | Fetches data from the active project's database and displays it as JSON. Supports querying on indexed data. |
| database:instances:create | Creates a database instance with a specified instance name. Accepts the--location option for creating a database in a specified region. For region names to use with this option, seeselect locations for your project. If no database instance exists for the current project, you are prompted to run thefirebase init flow to create an instance. |
| database:instances:list | List all database instances for this project. Accepts the--location option for listing databases in a specified region. For region names to use with this option seeselect locations for your project. |
| database:profile | Builds a profile of operations on the active project's database. For more details, refer toRealtime Database operation types. |
| database:push | Pushes new data to a list at a specified location in the active project's database. Takes input from a file, STDIN, or a command-line argument. |
| database:remove | Deletes all data at a specified location in the active project's database. |
| database:set | Replaces all data at a specified location in the active project's database. Takes input from a file, STDIN, or a command-line argument. |
| database:update | Performs a partial update at a specified location in the active project's database. Takes input from a file, STDIN, or a command-line argument. |
Remote Config commands
| Command | Description |
|---|---|
| remoteconfig:versions:list \ --limitNUMBER_OF_VERSIONS | Lists the most recent ten versions of the template. Specify0 to return all existing versions, or optionally pass the--limit option to limit the number of versions being returned. |
| remoteconfig:get \ --v, version_numberVERSION_NUMBER --o, outputFILENAME | Gets the template by version (defaults to the latest version) and outputs the parameter groups, parameters, and condition names and version into a table. Optionally, you can write the output to a specified file with-o,FILENAME. |
| remoteconfig:rollback \ --v, version_numberVERSION_NUMBER --force | Rolls backRemote Config template to a specified previous version number or defaults to the immediate previous version (current version -1). Unless--force is passed, promptsY/N before proceeding to rollback. |
| remoteconfig:experiments:list \ --filterEXPRESSION --pageSizeNUMBER --pageTokenTOKEN | Lists allRemote Config experiments for a project, with optional filtering, number of experiments to return per page (defaults to 10), and page token as the starting offset for the list. |
| remoteconfig:experiments:get \ EXPERIMENT_ID | Gets the details of the specifiedRemote Config experiment. |
| remoteconfig:experiments:delete \ EXPERIMENT_ID | Deletes the specifiedRemote Config experiment. |
| remoteconfig:rollouts:list \ --filterEXPRESSION --pageSizeNUMBER --pageTokenTOKEN | Lists allRemote Config rollouts for a project, with optional filtering, number of rollouts to return per page (defaults to 10), and page token as the starting offset for the list. |
| remoteconfig:rollouts:get \ ROLLOUT_ID | Gets the details of the specifiedRemote Config rollout. |
| remoteconfig:rollouts:delete \ ROLLOUT_ID | Deletes the specifiedRemote Config rollout. |
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-17 UTC.