Firebase cli change project

Firebase cli change project DEFAULT

Installing the Firebase CLI

The Firebase CLI is a utility used to administer Firebase projects and perform tasks such as Realtime Database management tasks from the command-line of a terminal or command-prompt window. The Firebase CLI is also the method by which Firebase Cloud Functions are deployed and managed.

This chapter covers the installation of the Firebase CLI before creating and testing a simple Firebase Cloud Functions project.

Installing Node.js

The Firebase CLI is built on Node.js and, as such, the first step in installing the CLI is to set up the Node.js environment. If you do not already have Node.js installed, refer to the steps outlined in the chapter entitled Sending Firebase Cloud Messages from a Node.js Server.

Installing the Firebase Tools Package

With Node.js installed, the next step is to install the Firebase Tools package using the following npm command within a terminal or command-prompt window:

npm install -g firebase-tools

Note that on some platforms such as macOS and Linux it may be necessary to execute the above command with super user privileges:

sudo npm install -g firebase-tools

Logging into Firebase

Before a new Cloud Functions project can be created it is necessary to sign into Firebase using the same account credentials used for access to the Firebase console. Installed as part of the Firebase Tools package is the Firebase CLI tool which can now be used to log into Firebase:

firebase login

The command will prompt for permission to gather anonymous usage data before displaying a browser window within which to select the Google account associated with your Firebase development projects. Select an account and agree to the terms and conditions. Once the login is complete the panel shown in Figure 53‑1 will appear in the browser window:

Firebase cli logged in.png

Figure 53‑1

Close the browser window and return to the terminal window. To logout at any point in the future, simply execute the following Firebase CLI command:

firebase logout

Creating a Cloud Functions Project

The Firebase CLI is also used to create new Firebase Cloud Functions projects. For this example a project named MyCloudFunctions will be created. Begin by creating a subdirectory named MyCloudFunctions in a suitable filesystem location in which to store the project. Change directory into the new project folder and run the following command to create the project:

firebase init functions

When executed, the initialization command will generate the following output:

Firebase cli init.png

Figure 53‑2

Using the up and down arrow keys on the keyboard, select the Firebase Examples project and press Enter. Select the option to install dependencies and wait for the initialization to complete.

Reviewing the Project

When the project creation is complete the project folder will contain the following files and directories:

.firebaserc – A script file used by the firebase use command to switch between projects.

firebase.json – The properties configuration file.

functions/package.json – The JSON configuration file for the project containing version number and dependency information.

functions/index.js – The source code file within which the Cloud Functions will be written.

functions/node_modules – Contains the dependency packages defined in the package.json file.

Deploying a Simple HTTP Cloud Function

Using your preferred editor, edit the index.js file located in the functions folder. By default, the first line of the file imports the firebase-functions package. This is a standard requirement for all cloud function source files:

const functions = require('firebase-functions');

The remainder of the file contains a commented out example HTTP cloud function. Remove the comment markers so that the function reads as follows:

// Create and Deploy Your First Cloud Functions // exports.helloWorld = functions.https.onRequest((request, response) => { response.send("Hello from Firebase!"); });

Save the file and deploy it using the following Firebase CLI command:

firebase deploy --only functions:helloWorld

This command will deploy only the helloWorld function. To deploy all of the functions in the index.js file, use the following command:

firebase deploy --only functions

Deployment of cloud functions can take a few minutes, but once the deployment is finished, the full output should read as follows:

Firebase cli deployment.png

Figure 53‑3

The final line of output contains the URL by which the cloud function will be triggered. Copy and paste this URL into a browser window and verify that the “Hello from Firebase!” message appears.

Edit the index.js file and modify the function to accept a query value as part of the URL and to output diagnostics to the log:

exports.helloWorld = functions.https.onRequest((request, response) => { const name =; console.log("Name = " + name); response.send("Hello from Firebase, " + name); });

Redeploy the app using the Firebase CLI then open the same URL, this time adding a query value:

https://<your server here>

When the web page now loads, the new message containing the name value should appear.

Reviewing the Logs

Cloud function logs can be accessed either using the Firebase CLI, or from within the Firebase console. To view log output using the CLI, simply run the following command:

firebase functions:log

Alternatively, select the Firebase Examples project in the Firebase console and click on the Functions link in the navigation panel. The Functions Dashboard screen will list the functions currently deployed for the project together with basic runtime and execution metrics:

Firebase cli runtime metrics.png

Figure 53‑4

Hovering over the function will display the menu dots (highlighted in the figure above). Open this menu and select the View logs option to view the log output for the function:

Firebase cli logs.png

Figure 53‑5

Removing a Deployed Function

To withdraw a cloud function from deployment, remove it from the index.js file (or comment it out) and then run the Firebase CLI deployment command:

firebase deploy –only functions

Firebase will detect the absence of the previously deployed function and delete it from the cloud.


Firebase Cloud Functions are deployed and managed using the Firebase CLI tool. This tool is built on Node.js and is installed using the npm command. Once installed, the Firebase CLI is used to sign into Firebase and create new Firebase Cloud Function projects. Once the project has been created, cloud functions are added to the index.js file and deployed to the cloud. In addition to outlining the installation process for Firebase CLI, this chapter also created, deployed and tested a simple HTTP cloud function.


You can transfer Firebase projects between projects by using IAM. App testing. If you find that your application caches too little or too much data, call this method to change the cache size. They should be posted to StackOverflow with the 'firebase' tag. After you generate a new private key, save it in the root folder .

Cloud Functions for Firebase lets you automatically run backend code in This is a tutorial on how you can create your first Firebase Cloud Function project. use the Firebase CLI to create our project, on the CMD/Terminal, change the directory and run the following command to create the project: firebase init functions,

For more examples and details about the automatic install script, refer to the To initialize a new Firebase project, run the following command from within By using different project environments, you can verify changes before The Firebase CLI manages deployment of code and assets to your Firebase project, including:.

We will be removing this since we are going to be building the React app. You should see this after running the init command. Then, select a default Firebase project for this directory: (Use arrow keys). Then Change the “public”: “public” to “public”: “app/build” or to your project name To access the code click here.

Table of contents. Priority order of Hosting responses. Specify which files to deploy. public. ignore. Customize a 404/Not Found page. Configure redirects. Capture URL segments for redirects. Configure rewrites. Direct requests to a function. Direct requests to a Cloud Run container. Configure headers. Control .html

Google Firebase lets you host your static website in a fast and secure manner for free. The project directory will be located in a folder at this path Note that you can enter a different name (such as "my_first_project') instead of "public". At this point, specify your public root directory, but you can also specify

Bring Back '90s On Stackoverflow Change The Usual Mouse Pointer To An Add A New Cursor File To Your Project: ' Project->Add New Item->General->Cursor File Run Would Automatically Open In The Current Directory The File (if After You Save The URL, It Will Be Used By All Of Your Firebase Project's

I want to change the language of the link that was generating the function Link a Firebase project to Google Ads: You'll need at least one Firebase project The Admin SDK Directory API lets administrators of enterprise domains view and the original Stack Overflow Documentation created by following contributors and

CLI administrative commands; Project management commands; Deployment and local test the Firebase CLI; Update to the latest CLI version; Use the CLI with CI systems to install the CLI and enable the globally available firebase command. Access the binary to open a shell where you can run the firebase command.

Stack Overflow for Teams is a private, secure spot for you and your coworkers to find If you're connected but you can't download content, change your Apple ID password. MacOS Xcode CoreSimulator folder, Caches … all are very big. your Firebase project by calling the createUserWithEmailAndPassword method or

During project initialization, from the Firebase CLI prompts: run this command with a comma-separated list in the flag (for example, your Hosting content and config to the following Firebase-provisioned subdomains: Test locally, share changes at a temporary preview URL, then deploy to your live site.

Deploy code and assets to your Firebase projects; Run a local web server for your To download and install the Firebase CLI run the following command: init, Setup a new Firebase project in the current directory. database:set, Replace all data at a specified location in the current project's database.

To build a React Native project, run the following command: In index.ios.js , let's change the component to use a class rather than React. Add each one of these components below to the components folder: If you're running into issues, open up a question on Stackoverflow, we monitor the Firebase

How would you group more than 4,000 active Stack Overflow tags into android-library, kotlinx.coroutines, firebase-mlkit, expandablelistview, azure: azure-ad-graph-api, azure-active-directory, azure-powershell, azure-ad-b2c ant, activemq, vaadin, spring-kafka, pom.xml, log4j2, project-reactor,

In this guide, you will learn how to deploy your Gatsby site to Firebase Hosting. Firebase When prompted to select your public directory, press enter . It will default This generates a publishable version of your site in the public folder. Deploy

Firebase Creating and Deploying Cloud Function with What is Firebase, Features, So, we will first download the Node.js from the following site: After that, we can confirm authentication by listing our Firebase projects.

For full details about installation options for the Firebase CLI # please see our We created it using a non-destructive mkdir command. sudo mkdir -p This turns these commands into no-ops so # when ran as a script, they're totally ignored. #

You'll get started with Firebase Tools by installing it. If you see bash: command not found: node , then you'll need to install Node.js. The Node.js community has moved toward putting all deploy commands in a package.json file, so let's

To connect you app to Firebase, you first need a Firebase project. Thanks for contributing an answer to Stack Overflow! or Android app com. plist and place them at android/app/ and ios/Runner/ directory respectively Change URL schema

The simplest getting started guide for Firebase Cloud functions. I was one of the first users of Firebase back in the day. In fact, I spearheaded their of your project. You can find it in the URL after your project is created:.

I believe firebase is hosting the public and the function folder differently or am I referencing just wrong? You can do this just by changing the public setting in firebase.json to be e.g. Can't import script from other folder

With Firebase Hosting, you can configure customized hosting behavior for The different Firebase Hosting configuration options described on this page can Only matches files and folders in the root of the public directory.

If you select to make a one-page app, then Firebase automatically adds To deploy to your site, run the following command from the root of your local run this command with a comma-separated list in the flag (for example,

While waiting for firebase-tools to support more firestore commands, I wrote a basic firestore client that you might find useful:

Install Firebase CLI using command. npm install -g firebase-tools. After getting it installed, need to login to firebase account before using firebase CLI commands, In order to login, run

Improve this answer. Follow. answered Jun 9 '20 at 18:01. user10314103. I tried this command in these order you mention it but still get same error and in this time interval i tried

Label images with your models. iOS. Android. Train object detection models. Detect objects with your models. iOS. Android. Migrate datasets. Use Cloud Vision APIs. Recognize text.

contributors collaborating on the project. See the full package health analysis to learn more about the package maintenance status. Last updated on 11 April-2021, at 11:13 (UTC).

loads, the new message containing the name value should appear. Reviewing the Logs. Cloud function logs can be accessed either using the Firebase CLI, or from within the Firebase

and Linux it may be necessary to execute the above command with super user privileges: sudo npm install -g firebase-tools. Logging into Firebase. Before a new Cloud Functions

OnDisconnect. PropertyName. Query. ServerValue. ThrowOnExtraProperties. Transaction. Overview. Handler. Result. ValueEventListener. Overview

Deployment. select the Firebase products you wish to setup. Be sure to select Firebase Hosting.. select the Firebase Project you wish to use or create a new one, if

By setting up multiple Hosting sites within the same Firebase project, you can "public": "app/dist", // contents of this folder are deployed to the site "myapp-app"

Using Firebase Hosting, we can deploy our application's static files (HTML, CSS, JavaScript, etc) Update the file to include the following rewrites configuration:

Each Hosting site can only be linked to a single Firebase Web App. You may need to link your web app to your Hosting site in the Project settings if you chose not

You can associate multiple Hosting sites with one Firebase project. Each site hosts its Add another site. Enter the name of the new site, then click Create site.

During project initialization, from the Firebase CLI prompts: rules for JavaScript linting. package.json : npm package file describing your Cloud Functions code.

Then, for “What do you want to use as your public directory? (public)” ENTER to use the public default setting. We will be removing this since we are going to be

After getting it installed, need to login to firebase account before using firebase CLI commands, In order to login, run this command There will be a new tab in

The firebase init command steps you through setting up your project directory and some Firebase products. During project initialization, the Firebase CLI asks

The modern web is secure. The content is always delivered securely because zero-configuration SSL is built into Firebase Hosting. It hosts static and dynamic

This deployment example refers to Firebase Hosting . To start, we need to update the custom-application-config.json file with the production URL (replace the

On Linux stacks, you can use the custom JSON field to override default AWS OpsWorks This can happen, for example, if you deploy your app as a .zip file that

Prerequisites: 1. Firebase project. 2. Very basic knowledge of Node.js. 3. Knowledge of NoSQL database. What is Firebase Cloud Function? Cloud Functions for

With Node.js installed, the next step is to install the Firebase Tools package using the following npm command within a terminal or command-prompt window:

The sample app, Playchat, stores chat messages in the Firebase Realtime Database, To build the backend servlet and deploy it in the App Engine flexible

You can install the Firebase CLI using npm (the Node Package Manager). Note that The command firebase --help lists the available commands and firebase

Right now, my public directory is specified in firebase.json like this: I want to set it up so I can serve a different folder depending on whether I …

This page explains how to deploy applications to Firebase using Cloud Build. To view a code sample for deploying to Firebase using Cloud Build, go to

GADInterstitialDelegate. GADMAdNetworkAdapter. GADMAdNetworkConnector. GADMRewardBasedVideoAdNetworkAdapter. GADMRewardBasedVideoAdNetworkConnector

Start a local server with your Firebase Hosting configuration and HTTPS-triggered Cloud Functions. Relies on firebase.json . Auth Commands. Command

Before you begin; Step 1: Install the Firebase CLI; Step 2: Initialize your project files to your Firebase project, run the following command from

When you first initialize your Firebase Hosting project with firebase init If you want to switch to another environment, just provide the alias in

Now, let's bootstrap a Firebase project. Go to an empty directory and run the following: firebase init. You'll be greeted with a colorful console

create-login-config. gcloud api-gateway. Overview. api-configs. Overview. create. delete. describe. list. update. apis. Overview. add-iam-policy

This is where the JavaScript code will go. This folder contains a NPM project with a package.json file and a index.js where the Cloud functions

Create a Firebase project. Go to the Firebase Console. Log in or create your account. Once on the home page, click the big "Add project" button

With that done, you can successfully create your Firebase project. our database created, we can now write and deploy our first cloud function.

Firebase Hosting is a web application hosting platform by Google. For example, rather than building pages from scratch, figuring out routing,

Create an application based on the example deployment images found in The Custom strategy allows you to provide your own deployment behavior.

In this example, we will add the following text. <h1>WELCOME TO FIREBASE TUTORIALS APP</h1>. Step 1 - Install Firebase Tools. We

Get code examples like "change firebase project after firebase init" instantly right from your google search results with the Grepper Chrome

And hit enter. And you will see a public folder is created in addition to three other files. Now what we need to do is cut all our websites

Connect the local project directory (containing your app's content) to We recommend setting up a separate Firebase project for testing and

Do you manage multiple Firebase Hosting sites? Do these The CLI uses this target to know what "public" folder to use for deploying assets.

Human operators who look after specific applications and services to deploy an Operator is to add the Custom Resource Definition and its

You can optionally deploy your app's Hosting content and config, but it's Replace CHANNEL_ID with a string with no spaces (for example,

You can install the Firebase CLI using npm (the Node Package Manager). The command firebase --help lists the available commands and

Before you begin. Before you can set up Firebase Hosting, you need to create a Firebase project. Step 1: Install the Firebase CLI.

  1. Fire emblem freyja
  2. West marine fishing cart
  3. Mossberg 500 barrel

Example Deployment with Firebase

This deployment example refers to Firebase Hosting.


Before you get started, you need to have:

Create a Firebase project

  1. In the Firebase console click Add project, then select or enter a Project name.

    If you have an existing Google Cloud Platform (GCP) project, you can select the project from the dropdown menu to add Firebase resources to that project.

  2. (Optional) Edit the Project ID.

    The project ID displays in publicly visible Firebase resources, for example as the default Hosting subdomain - or This is the only opportunity to change your project ID.

  3. Click Continue.

  4. (Optional) Set up Google Analytics for your project.

  5. Click Create project (or Add Firebase, if you're using an existing GCP project).

Initialize your project

To connect your local project to your Firebase project, run the following command from the root of your local project directory:

During project initialization, from the Firebase CLI prompts:

  1. Select to set up Hosting and Functions.

  2. Select the Firebase project, which you have created in the previous section, to connect it to your local project directory.

  3. Select JavaScript as language for writing Cloud Functions.

  4. Choose whether you would like to use ESLint and install dependencies with npm (both recommended) or if you want to manage dependencies in another way.

  5. Select the default directory as your public root directory. This directory is and all compiled files will be placed there.

  6. Configure your site as single-page app to automatically add rewrite configurations.

    Firebase Initialization

After initialization, Firebase automatically creates and adds two files to the root of your local app directory:

  • A configuration file that lists your project configuration.

  • A file that stores your project aliases.

To support Cloud Functions, Firebase also adds the following structure to your project:


└── functions

├── .eslintrc.json

├── index.js

├── node_modules/

└── package.json

  • : optional file containing rules for JavaScript linting.
  • : npm package file describing your Cloud Functions code.
  • : main source file for your Cloud Functions code.


To start, we need to update the file with the production URL (replace the with the real Firebase project ID):



"name":"My app",









To configure Firebase deployments, we need to use a file. Normally, it would look something like this:










"source":"**/*[email protected](|js|css|txt|html|png)",














Some fields may vary based on your setup and requirements, for example , , etc.

However, that won't work as the Custom Application does not have an after building the production bundles. To make it work, we need to compile the application first.

Compile the application

To be able to deploy the Custom Application to Firebase, the Custom Application needs to be compiled.

The command above does what we need: it compiles the using the JavaScript bundle references (after running ) and the runtime configuration. At this point the file is ready for production usage.

However, the Custom Application needs to instruct the User-Agent (the browser) to enforce certain security measures, using HTTP headers (done automatically by the application config).

Because of that, the function file cannot be defined statically. Instead, it needs to be generated programmatically when the Custom Application is built and compiled. To achieve that, we need to implement a transformer function.

Generate function using a transformer function

The command accepts an option which we can use to pass the filesystem path to our transformer function.

We assume that the transformer function is defined at the following location: .

mc-scripts compile-html \

--transformer $(pwd)/config/transformer-firebase.js

The purpose of the transformer function is to generate the final file given the compiled values passed to the function.







The main export of the file should be the transformer function.




With that in mind, we can implement the transformer function and write the config into the filesystem.


const fs =require('fs');

const path =require('path');

const rootPath = path.join(__dirname,'..');

module.exports=({ headers })=>{

const config ={





{ source:'**', destination:'/index.html'},




source:'**/*[email protected](|js|css|txt|html|png)',


{ key:'Cache-Control', value:'s-maxage=31536000,immutable'},








}).map(([key, value])=>({ key, value })),





const target = process.env.FIREBASE_TARGET;

if(target){ target;





{ encoding:'utf8'}



Adding fallback routes

This step is optional and does not prevent the application to be used within the Merchant Center. However, it's recommended to do so to avoid unexpected behaviors in case the URL, where the Custom Application is hosted, is accessed directly.

Accessing the Custom Application directly at won't work, as the application requires the user to log in and thus tries to redirect to the route at the same domain.

To prevent that, we can add a dummy fallback route for the routes. This is only meant to inform the user that the Custom Application cannot be used standalone.


exports.customAppFallback= functions.https.onRequest((req, res)=>{


'This is not a real route. If you are seeing this, you most likely are accessing the Custom Application\n'+

'directly from the hosted domain. Instead, you need to access the Custom Application from within the Merchant Center\n'+

'domain, as Custom Applications are served behind a proxy router.\n'+

'To do so, you need to first register the Custom Application in Merchant Center > Settings > Custom Applications.'



This route will be used as a serverless function:


const fs =require('fs');

const path =require('path');

const rootPath = path.join(__dirname,'..');

module.exports=({ headers })=>{

const config ={





{ source:'**', destination:'/index.html'},

{ source:'/@(login|logout)',function:'customAppFallback'},




source:'**/*[email protected](|js|css|txt|html|png)',


{ key:'Cache-Control', value:'s-maxage=31536000,immutable'},








}).map(([key, value])=>({ key, value })),





const target = process.env.FIREBASE_TARGET;

if(target){ target;





{ encoding:'utf8'}



Set up a Hosting Site (optional)

You can set up one or more Firebase Hosting sites in a single Firebase project. This is useful if you would like to host multiple Custom Applications on a single Firebase/GCP project.

Add an additional site directly from your Firebase Hosting page.

Firebase Hosting

Firebase Hosting Site

When you have multiple sites and you run Firebase CLI deploy commands, the CLI needs a way to communicate which settings should be deployed to each site. With deploy targets you can uniquely identify a specific site by its target name in your configuration file and in your Firebase CLI commands for testing or deploying to your sites.

To create a deploy target and apply a target name to a Hosting site, run the following CLI command from the root of your project directory:

firebase target:apply hosting target-name resource-name

Where the parameters are:

  • target-name: a unique identifier (that you've defined yourself) for the Hosting site that you're deploying to.

  • resource-name: the name of the Hosting site as listed in your Firebase project.

Firebase Hosting Console

The settings for deploy targets are stored in the file in your project directory, so you only need to set up deploy targets once per project.

If you have configured a deploy target in a previous section, prefix the command with the , where is the unique identifier previously defined.

The assets compiled into the directory will be deployed to Firebase.


Finally, we can trigger the deployment using the Firebase CLI:

yarn build

mc-scripts compile-html \

--transformer $(pwd)/config/transformer-firebase.js

firebase deploy

Now you're ready to Register your Custom Application and start using it!


How do I switch apps from the firebase cli?

I may be wrong but it seems that the original question was about changing apps within a given project, rather than simply changing projects.

This answer is about changing apps and site_IDs within a project.

In my case I have a project (CoolProject) with 2 web apps:

  • an assessment form:
  • a main website:

Both apps are in separate repos both locally and in GitHub.

Each app has its own specific site_ID:

  • form:
  • website:

I first setup the app and deployed without any issue to . But when I created the app (and associated site_ID) and tried to deploy it using or it incorrectly deployed it to overwriting the app.

This is how I eventually solved the issue (based on this Firebase documentation):

  1. Check that both apps and corresponding site_IDs are correctly setup:
  1. Setup up the deploy target for hosting (via )
  1. Update (for the app):
  1. Deploy

With this the app is now correctly deployed to .


Change firebase project cli

Firebase CLI Actions StatusNode VersionNPM 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.


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 command.

Standalone Binary

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

To download and install the CLI run the following command:

curl -sL | bash


The command lists the available commands and 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 flag.

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

Configuration Commands

loginAuthenticate to your Firebase account. Requires access to a web browser.
logoutSign out of the Firebase CLI.
login:ciGenerate an authentication token for use in non-interactive environments.
login:addAuthorize the CLI for an additional account.
login:listList authorized CLI accounts.
login:useSet the default account to use for this project
useSet active Firebase project, manage project aliases.
openQuickly open a browser to relevant project resources.
initSetup a new Firebase project in the current directory. This command will create a configuration file in your current directory.
helpDisplay help information about the CLI or specific commands.

Append to login (i.e., ) 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

apps:createCreate a new Firebase app in a project.
apps:listList the registered apps of a Firebase project.
apps:sdkconfigPrint the configuration of a Firebase app.
projects:addfirebaseAdd Firebase resources to a Google Cloud Platform project.
projects:createCreate a new Firebase project.
projects:listPrint a list of all of your Firebase projects.

Deployment and Local Emulation

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

emulators:execStart the local Firebase emulators, run a test script, then shut down the emulators.
emulators:startStart the local Firebase emulators.
deployDeploys your Firebase project. Relies on configuration and your local project folder.
serveStart a local server with your Firebase Hosting configuration and HTTPS-triggered Cloud Functions. Relies on .
setup:emulators:databaseDownloads the database emulator.
setup:emulators:firestoreDownloads the firestore emulator.

App Distribution Commands

appdistribution:distributeUpload a distribution.

Auth Commands

auth:importBatch importing accounts into Firebase from data file.
auth:exportBatch exporting accounts from Firebase into data file.

Detailed doc is here.

Realtime Database Commands

database:getFetch data from the current project's database and display it as JSON. Supports querying on indexed data.
database:setReplace all data at a specified location in the current project's database. Takes input from file, STDIN, or command-line argument.
database:pushPush 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:removeDelete all data at a specified location in the current project's database.
database:updatePerform a partial update at a specified location in the current project's database. Takes input from file, STDIN, or command-line argument.
database:profileProfile database usage and generate a report.
database:instances:createCreate a realtime database instance.
database:instances:listList realtime database instances.
database:settings:getRead the realtime database setting at path
database:settings:setSet the realtime database setting at path.

Extensions Commands

extDisplay information on how to use ext commands and extensions installed to your project.
ext:configureConfigure an existing extension instance.
ext:infoDisplay information about an extension by name ([email protected] for a specific version)
ext:installInstall an extension.
ext:listList all the extensions that are installed in your Firebase project.
ext:uninstallUninstall an extension that is installed in your Firebase project by Instance ID.
ext:updateUpdate an existing extension instance to the latest version.

Cloud Firestore Commands

firestore:deleteDelete documents or collections from the current project's database. Supports recursive deletion of subcollections.
firestore:indexesList all deployed indexes from the current project.

Cloud Functions Commands

functions:logRead logs from deployed Cloud Functions.
functions:config:setStore runtime configuration values for the current project's Cloud Functions.
functions:config:getRetrieve existing configuration values for the current project's Cloud Functions.
functions:config:unsetRemove values from the current project's runtime configuration.
functions:config:cloneCopy runtime configuration from one project environment to another.
functions:deleteDelete one or more Cloud Functions by name or group name.
functions:shellLocally emulate functions and start Node.js shell where these local functions can be invoked with test data.

Hosting Commands

hosting:disableStop 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

remoteconfig:getGet a Firebase project's Remote Config template.
remoteconfig:versions:listGet a list of the most recent Firebase Remote Config template versions that have been published.
remoteconfig:rollbackRoll back a project's published Remote Config template to the version provided by flag.

Use to update and publish a project's Firebase Remote Config template.



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

  • User Token - provide an explicit long-lived Firebase user token generated from . 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 flag on any command, for example .
    • Set the environment variable.
  • Local Login - run to log in to the CLI directly as yourself. The CLI will cache an authorized user credential on your machine.
  • Service Account - set the environment variable to point to the path of a JSON service account key file.
  • Application Default Credentials - if you use the CLI and log in with , the Firebase CLI will use them if none of the above credentials are present.

Multiple Accounts

By default 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 . You can view the list of authorized accounts with .

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

To set the account for a specific command invocation, use the flag with any command. For example . The specified account must have already been added to the Firebase CLI using .

Cloud Functions Emulator

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

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

Using behind a proxy

The CLI supports HTTP(S) proxies via environment variables. To use a proxy, set the or value in your environment to the URL of your proxy (e.g. ).

Using with CI Systems

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

  1. On a machine with a browser, install the Firebase CLI.
  2. Run to log in and print out a new refresh token (the current CLI session will not be affected).
  3. Store the output token in a secure but accessible way in your CI system.

There are two ways to use this token when running Firebase commands:

  1. Store the token as the environment variable and it will automatically be utilized.
  2. Run all commands with the flag in your CI system.

The order of precedence for token loading is flag, environment variable, active project.

On any machine with the Firebase CLI, running will immediately revoke access for the specified token.

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:

constclient=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:

constclient=require("firebase-tools");// #1 - No arguments or options, defaults will be inferredclient.apps.list();// #2 - Explicitly provide "" for all arguments and {} for optionsclient.apps.list("",{});

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

Changing Package and Firebase Setup

How to show your current Firebase project name on the command line prompt to prevent dangerous errors

by Thang Minh Vu

When working on a project with multiple stages (development, staging, production), developers use the command to switch between projects. It’s very easy to run a command on the production environment instead of the development. This is very dangerous.

Note: You can always find the latest script at my GitHub repository.

Normally, developers only work on the development project. They only switch to production in case of checking or doing a hotfix. There have been a few times when I forgot to switch back to the development project. I accidentally changed the database without thinking that it could impact the actual users.

Digging into the firebase CLI, I found that it uses configstore to manage local configuration. All config is saved in a JSON file and reads easily. I created a small script which is intended to show the firebase project name on shell prompt.

How to set it up


Add the following script to the end of :

Then run or open a new terminal window:

iTerm2 with oh-my-zsh

Oh-my-zsh is a popular open source framework for Zshell. I like it because it has many beautiful terminal themes and many useful plugins.

Here, I will make an example with the agnoster theme:

and then add to functions:

For the final step, run or open a new terminal window:

I hope this can help you prevent the an unexpected (and bad) situation.

Note: You can always find the latest script at my GitHub repository.

If this article was helpful, tweet it.

Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. Get started


Similar news:

The truth is - the first time of doing scientific work somehow went to - not even the second, but the "tenth plan" - due to the fact that both. "partners" were slightly maddened by their sexual experiments. In the meantime, they even managed to submit an application to the registry office and register a marriage (on a secret.

From Lenin's parents, who did not want her to marry before she would defend a candidate's dissertation).

2689 2690 2691 2692 2693