Core Firebase CLI utilities for authentication, project management, and general operations.
Authenticates the Firebase CLI to your Google account.
/**
* Authenticate to Firebase
* @param options - Authentication options
* @returns Promise resolving when authentication completes
*/
function login(options?: Options & {
/** Force re-authentication */
reauth?: boolean;
/** Use localhost for auth redirect */
localhost?: boolean;
}): Promise<void>;Generates a CI token for use in continuous integration environments.
/**
* Generate CI authentication token
* @param options - CI token options
* @returns Promise resolving to CI token information
*/
function loginCi(options?: Options): Promise<{
token: string;
expires?: string;
}>;Adds an additional Google account for multi-account management.
/**
* Add additional authentication account
* @param options - Add account options
* @returns Promise resolving when account is added
*/
function loginAdd(options?: Options): Promise<void>;Lists all authenticated accounts.
/**
* List authenticated accounts
* @param options - Command options
* @returns Promise resolving to array of account information
*/
function loginList(options?: Options): Promise<Array<{
email: string;
active: boolean;
}>>;Sets the active/default account.
/**
* Set active authentication account
* @param email - Email of account to make active
* @param options - Command options
* @returns Promise resolving when account is activated
*/
function loginUse(email: string, options?: Options): Promise<void>;Signs out of Firebase and clears authentication.
/**
* Sign out of Firebase
* @param options - Logout options
* @returns Promise resolving when logout completes
*/
function logout(options?: Options): Promise<void>;Authentication Examples:
const client = require("firebase-tools");
// Login to Firebase
await client.login();
// Login with re-authentication
await client.login({ reauth: true });
// Generate CI token
const ciToken = await client.login.ci();
console.log("CI Token:", ciToken.token);
// Add additional account
await client.login.add();
// List all accounts
const accounts = await client.login.list();
console.log("Authenticated accounts:", accounts);
// Switch active account
await client.login.use("user@example.com");
// Logout
await client.logout();Initializes a Firebase project in the current directory.
/**
* Initialize Firebase project
* @param options - Initialization options
* @returns Promise resolving when initialization completes
*/
function init(options?: Options & {
/** Services to initialize (comma-separated) */
only?: string;
/** Initialize with default settings */
defaults?: boolean;
}): Promise<void>;Sets the active Firebase project for the current directory.
/**
* Set active Firebase project
* @param projectId - Project ID to activate
* @param options - Command options
* @returns Promise resolving when project is activated
*/
function use(projectId: string, options?: Options): Promise<void>;Opens Firebase project resources in the default browser.
/**
* Open project resources in browser
* @param options - Open options
* @returns Promise resolving when browser opens
*/
function open(options?: Options & {
/** Specific resource to open */
resource?: "overview" | "hosting" | "database" | "firestore" | "functions" | "extensions";
}): Promise<void>;Project Management Examples:
// Initialize project with specific services
await client.init({
only: "hosting,functions,firestore",
defaults: false
});
// Set active project
await client.use("my-project-id");
// Open project overview
await client.open({
project: "my-project",
resource: "overview"
});
// Open hosting dashboard
await client.open({
project: "my-project",
resource: "hosting"
});Starts a local development server for Firebase Hosting.
/**
* Start local development server
* @param options - Server options
* @returns Promise resolving when server stops
*/
function serve(options?: Options & {
/** Port for the server */
port?: number;
/** Host for the server */
host?: string;
/** Serve only specific targets */
only?: string;
}): Promise<void>;Development Server Examples:
// Start development server
await client.serve({
project: "my-project",
port: 5000,
host: "localhost"
});
// Serve only hosting
await client.serve({
project: "my-project",
only: "hosting",
port: 8080
});Applies a deployment target to a resource.
/**
* Apply deployment target
* @param type - Target type (hosting, storage, etc.)
* @param name - Target name
* @param resource - Resource identifier
* @param options - Command options
* @returns Promise resolving when target is applied
*/
function targetApply(
type: string,
name: string,
resource: string,
options?: Options
): Promise<void>;Clears deployment targets for a resource type.
/**
* Clear deployment targets
* @param type - Target type to clear
* @param options - Command options
* @returns Promise resolving when targets are cleared
*/
function targetClear(type: string, options?: Options): Promise<void>;Removes a specific deployment target.
/**
* Remove deployment target
* @param type - Target type
* @param name - Target name
* @param options - Command options
* @returns Promise resolving when target is removed
*/
function targetRemove(
type: string,
name: string,
options?: Options
): Promise<void>;Lists all deployment targets.
/**
* List deployment targets
* @param options - Command options
* @returns Promise resolving to targets information
*/
function target(options?: Options): Promise<Record<string, any>>;Deployment Targets Examples:
// Apply hosting target
await client.target.apply("hosting", "staging", "my-site-staging", {
project: "my-project"
});
// Apply storage target
await client.target.apply("storage", "images", "my-images-bucket", {
project: "my-project"
});
// List all targets
const targets = await client.target({
project: "my-project"
});
// Clear hosting targets
await client.target.clear("hosting", {
project: "my-project"
});
// Remove specific target
await client.target.remove("hosting", "staging", {
project: "my-project"
});Displays help information for Firebase CLI commands.
/**
* Display help information
* @param command - Specific command to get help for
* @param options - Help options
* @returns Promise resolving when help is displayed
*/
function help(command?: string, options?: Options): Promise<void>;Help Examples:
// Show general help
await client.help();
// Show help for specific command
await client.help("deploy");
// Show help for command group
await client.help("functions");Firebase CLI respects several environment variables:
FIREBASE_TOKEN: CI authentication tokenGOOGLE_APPLICATION_CREDENTIALS: Path to service account key fileFIREBASE_PROJECT: Default project IDFIREBASE_CONFIG_PATH: Path to firebase.jsonFIREBASE_CLI_EXPERIMENTS: Comma-separated list of enabled experimentsEnvironment Usage Examples:
# Set CI token
export FIREBASE_TOKEN="your-ci-token"
# Set default project
export FIREBASE_PROJECT="my-default-project"
# Use service account
export GOOGLE_APPLICATION_CREDENTIALS="./service-account.json"
# Enable experiments
export FIREBASE_CLI_EXPERIMENTS="webframeworks,pintags"