Firebase Hosting management for deploying and managing static websites with global CDN, custom domains, and preview channels.
Disables Firebase Hosting for a site, making it inaccessible.
/**
* Disable Firebase Hosting
* @param options - Disable options
* @returns Promise resolving when hosting is disabled
*/
function disable(options?: Options & {
/** Hosting site ID */
site?: string;
/** Confirm the operation */
confirm?: boolean;
}): Promise<void>;Usage Examples:
const client = require("firebase-tools");
// Disable default hosting site
await client.hosting.disable({
project: "my-project",
confirm: true
});
// Disable specific site
await client.hosting.disable({
project: "my-project",
site: "my-site-staging",
confirm: true
});Clones hosting configuration from one site to another.
/**
* Clone hosting configuration between sites
* @param source - Source site identifier
* @param target - Target site identifier
* @param options - Clone options
* @returns Promise resolving when configuration is cloned
*/
function clone(
source: string,
target: string,
options?: Options
): Promise<void>;Usage Examples:
// Clone configuration between sites
await client.hosting.clone(
"my-site-prod",
"my-site-staging",
{ project: "my-project" }
);Creates a new Firebase Hosting site.
/**
* Create Firebase Hosting site
* @param options - Site creation options
* @returns Promise resolving when site is created
*/
function sitesCreate(options: Options & {
/** Site ID */
siteId: string;
/** App ID to associate with site */
appId?: string;
}): Promise<{
name: string;
defaultUrl: string;
appId?: string;
labels?: Record<string, string>;
}>;Lists all Firebase Hosting sites in the project.
/**
* List Firebase Hosting sites
* @param options - Command options
* @returns Promise resolving to array of site information
*/
function sitesList(options?: Options): Promise<Array<{
name: string;
defaultUrl: string;
appId?: string;
labels?: Record<string, string>;
type: string;
}>>;Gets detailed information about a specific hosting site.
/**
* Get Firebase Hosting site information
* @param options - Command options
* @returns Promise resolving to site details
*/
function sitesGet(options?: Options & {
/** Site ID */
siteId: string;
}): Promise<{
name: string;
defaultUrl: string;
appId?: string;
labels?: Record<string, string>;
type: string;
}>;Deletes a Firebase Hosting site.
/**
* Delete Firebase Hosting site
* @param options - Site deletion options
* @returns Promise resolving when site is deleted
*/
function sitesDelete(options: Options & {
/** Site ID to delete */
siteId: string;
/** Force deletion without confirmation */
force?: boolean;
}): Promise<void>;Site Management Examples:
// Create new hosting site
await client.hosting.sites.create({
project: "my-project",
siteId: "my-new-site"
});
// List all sites
const sites = await client.hosting.sites.list({
project: "my-project"
});
// Get site details
const siteInfo = await client.hosting.sites.get({
project: "my-project",
siteId: "my-site"
});
// Delete site
await client.hosting.sites.delete({
project: "my-project",
siteId: "old-site",
force: true
});Creates a preview channel for testing deployments.
/**
* Create hosting preview channel
* @param options - Channel creation options
* @returns Promise resolving when channel is created
*/
function channelCreate(options: Options & {
/** Channel ID */
channelId: string;
/** Site ID */
site?: string;
/** Channel expiration time */
expires?: string;
/** Time to live (e.g., '7d', '24h') */
ttl?: string;
}): Promise<{
name: string;
url: string;
expireTime?: string;
labels?: Record<string, string>;
}>;Lists all preview channels for a site.
/**
* List hosting preview channels
* @param options - Command options
* @returns Promise resolving to array of channel information
*/
function channelList(options?: Options & {
/** Site ID */
site?: string;
}): Promise<Array<{
name: string;
url: string;
expireTime?: string;
labels?: Record<string, string>;
createTime: string;
updateTime: string;
}>>;Deploys content to a preview channel.
/**
* Deploy to hosting preview channel
* @param options - Channel deployment options
* @returns Promise resolving when deployment completes
*/
function channelDeploy(options: Options & {
/** Channel ID */
channelId: string;
/** Site ID */
site?: string;
/** Only deploy hosting */
only?: string;
}): Promise<{
status: "success" | "error";
hosting?: {
site: string;
url: string;
expireTime?: string;
};
}>;Deletes a preview channel.
/**
* Delete hosting preview channel
* @param options - Channel deletion options
* @returns Promise resolving when channel is deleted
*/
function channelDelete(options: Options & {
/** Channel ID to delete */
channelId: string;
/** Site ID */
site?: string;
/** Force deletion without confirmation */
force?: boolean;
}): Promise<void>;Opens a preview channel in the default browser.
/**
* Open hosting preview channel in browser
* @param options - Open options
* @returns Promise resolving when browser opens
*/
function channelOpen(options: Options & {
/** Channel ID to open */
channelId: string;
/** Site ID */
site?: string;
}): Promise<void>;Channel Management Examples:
// Create preview channel
await client.hosting.channel.create({
project: "my-project",
channelId: "feature-branch",
ttl: "7d"
});
// List all channels
const channels = await client.hosting.channel.list({
project: "my-project"
});
// Deploy to channel
await client.hosting.channel.deploy({
project: "my-project",
channelId: "feature-branch",
only: "hosting"
});
// Open channel in browser
await client.hosting.channel.open({
project: "my-project",
channelId: "feature-branch"
});
// Delete channel
await client.hosting.channel.delete({
project: "my-project",
channelId: "old-feature",
force: true
});Hosting behavior is configured in firebase.json:
{
"hosting": {
"public": "dist",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "/api/**",
"function": "api"
},
{
"source": "**",
"destination": "/index.html"
}
],
"redirects": [
{
"source": "/old-page",
"destination": "/new-page",
"type": 301
}
],
"headers": [
{
"source": "**/*.@(jpg|jpeg|gif|png|svg|webp)",
"headers": [
{
"key": "Cache-Control",
"value": "max-age=7200"
}
]
}
]
}
}For multiple hosting sites in one project:
{
"hosting": [
{
"site": "my-site-prod",
"public": "dist-prod",
"ignore": ["firebase.json", "**/.*"]
},
{
"site": "my-site-staging",
"public": "dist-staging",
"ignore": ["firebase.json", "**/.*"]
}
]
}