LinuxCommandLibrary

firebase

Manage Firebase projects and deployments

TLDR

Log in to

$ firebase login
copy

List existing Firebase projects
$ firebase projects:list
copy

Start an interactive wizard to create a Firebase project in the current directory
$ firebase init
copy

Deploy code and assets to the current Firebase project
$ firebase deploy
copy

Start a local server to statically host the current Firebase project's assets
$ firebase serve
copy

Start an interactive wizard to open one of many links of the current Firebase project in the default web browser
$ firebase open
copy

SYNOPSIS

firebase <command> [options]
firebase [global-options]

PARAMETERS

--help, -h
    Displays help information for the Firebase CLI itself or for a specified subcommand.
Example: firebase --help or firebase deploy --help

--version, -v
    Outputs the version number of the Firebase CLI currently installed.

--debug
    Enables debug mode, providing more verbose output which can be helpful for troubleshooting issues.

--project <alias_or_id>
    Specifies the Firebase project to use for the command. This can be a project ID or an alias defined in your .firebaserc file.

--token <token>
    Authenticates using a specific Firebase access token instead of logging in via the browser. This is particularly useful for CI/CD environments.

--non-interactive
    Runs the command in non-interactive mode, suppressing prompts and requiring all necessary information to be provided via command-line options or environment variables. Ideal for automated scripts.

DESCRIPTION

The Firebase CLI is a powerful command-line interface provided by Google for interacting with and managing your Firebase projects directly from your local machine. It serves as the primary tool for developers to automate and streamline many common tasks associated with building and deploying Firebase applications. The CLI allows you to perform a wide range of operations, including
deploying web applications and static assets to Firebase Hosting,
deploying serverless backend logic to Cloud Functions for Firebase,
managing Realtime Database and Cloud Firestore data, security rules, and indexes,
initializing new Firebase projects and linking them to existing ones, and
emulating various Firebase services (like Hosting, Functions, Firestore, Realtime Database, Authentication, and Pub/Sub) locally during development for faster iteration and testing.
It significantly enhances the development workflow for applications built on the Firebase platform, enabling rapid iteration, efficient deployment, and robust local testing capabilities.

CAVEATS

The Firebase CLI requires Node.js and npm (Node Package Manager) to be installed on your system for its installation and operation.
You must authenticate your CLI with your Google account using firebase login before you can manage your projects.
For new projects, an initial setup via firebase init is typically required to configure project settings and create necessary files.
Many changes made locally, such as code for Hosting or Functions, require explicit deployment using firebase deploy to be reflected in your live Firebase project.
Each subcommand has its own specific set of options and arguments, which can be viewed using the --help flag with that subcommand.

<B>KEY SUBCOMMANDS</B>

The Firebase CLI is structured around numerous subcommands, each responsible for a specific aspect of Firebase project management. Some of the most frequently used include:
firebase init: Sets up a new Firebase project in the current directory, linking it to your remote Firebase project.
firebase deploy: Deploys your project's code to Firebase Hosting, Cloud Functions, and Realtime Database/Cloud Firestore security rules.
firebase serve: Serves your Firebase Hosting content locally for testing.
firebase emulators:start: Starts local emulators for various Firebase services (e.g., Hosting, Functions, Firestore, Realtime Database, Authentication, Pub/Sub) to enable offline development and testing.
firebase functions:log: Displays recent logs for your Cloud Functions, useful for debugging.

<B>INSTALLATION</B>

The Firebase CLI is distributed as an npm package. To install it globally on your system, open your terminal or command prompt and use the following command:
npm install -g firebase-tools
Ensure you have Node.js and npm installed on your system before attempting the installation.

HISTORY

Firebase, originally an independent company, was acquired by Google in 2014, leading to its integration into the Google Cloud ecosystem. The Firebase CLI was developed as a crucial tool to empower developers with a command-line interface for managing their Firebase projects efficiently. Its evolution has closely mirrored the growth of the Firebase platform itself, with continuous updates to support new services like Cloud Functions, Cloud Firestore, Firebase Extensions, and local emulators. The CLI has become an indispensable component in modern web and mobile development workflows, especially for those leveraging CI/CD pipelines for Firebase applications.

SEE ALSO

npm(1), node(1), gcloud(1), git(1)

Copied to clipboard