Manage live & preview channels, releases, and versions for your site

Firebase Hosting provides tooling via both the Firebase console and the Firebase CLI to manage the channels, releases, and versions for your Hosting site.

Overview of the Hosting infrastructure

Understanding the Hosting infrastructure helps you to understand the management options described on this page.

Every Firebase project has a default Hosting site with access to all the project's resources (databases, authentication, functions, etc.). A site contains one or more channels, where each channel is associated with a URL that serves specific content and a Hosting configuration.

an image of Firebase Hosting hierarchy

Every Hosting site has a "live" channel that serves content and a Hosting config at (1) the site's Firebase-provisioned subdomains (SITE_ID.web.app and SITE_ID.firebaseapp.com) and (2) any connected custom domains. You can also optionally create "preview" channels that serve their own content and configuration at temporary, sharable "preview URLs" (SITE_ID--CHANNEL_ID-RANDOM_HASH.web.app).

The content and configuration served by each channel is packaged into a version object that has a unique identifier. When you deploy to your site, Firebase creates a release object that points to a specific version. A release contains metadata about the deployment, like who deployed and when they deployed.

From your Firebase project's Hosting dashboard, you can see a full history of your live channel's releases in a Release history table. If you have multiple Hosting sites, click View for the desired site to see its release history. If you have any preview channels, they are also displayed on the Hosting dashboard.

Manage a channel's settings

For each channel of your site, you can control its settings. Some settings, like channel expiration, are only applicable for preview channels.

Limit the number of releases to keep

Each time you deploy to a channel (and create a release), Hosting keeps the version associated with the previous release in your project's Hosting storage. You can set the number of releases to keep for each channel in your project, both live and preview channels.

  • Why does Hosting keep previous releases?
    For your live channel, keeping previous releases enables you to roll back to a previous version of your site, if needed. For your preview channels, rolling back is not yet available.

  • Why limit the number of releases to keep?
    This feature can help you control the usage level of your project's Hosting storage, as the content for previous releases is kept in this storage. You can monitor your Hosting storage from the Storage tab in the console.

  • What happens when you limit the releases to keep?
    When you set a limit for releases to keep, the content of any releases over your set limit is scheduled for deletion, starting with the oldest releases first.

Here's how to set the release storage limit for a channel:

  1. In the Firebase console, access the release storage setting dialog:

    • For your live channel
      In the Release History table for your site, click , then select Release storage settings.

    • For any preview channel
      In the row for the preview channel, click , then select Channel settings.

  2. Enter the number of releases that you'd like to keep, then click Save.

Set the expiration of a preview channel

By default, a preview channel expires 7 days from its creation date, but your site's live channel will never expire.

When a preview channel expires, the channel, along with its releases and associated versions, are scheduled for deletion within 24 hours. The associated preview URL is also deactivated. An exception to this version-deletion is if a version is associated with another release (this happens, for example, if you clone a version from one channel to another within the same site).

Hosting supports two different ways to control the expiration of a channel:

  • Firebase console
    In the row for the preview channel, click , then select Channel settings. Enter the date and time for expiration.

  • Firebase CLI
    When you deploy to your preview channel, pass the --expires DURATION flag, for example:

    firebase hosting:channel:deploy new-awesome-feature --expires 7d

    The expiration can be up to 30 days from the date of deploy. Use h for hours, d for days, and w for weeks (for example, 12h, 7d, 2w, respectively).

Clone a version from one channel to another

You can clone a deployed version from one channel to a different channel. You can clone across live or preview channels, across Hosting sites, or even across Firebase projects.

The clone command also deploys to the "target" channel so that the cloned Hosting content and config are automatically served at the "target" channel's associated URL.

This feature is useful for version tracking or if you want confidence that you're deploying the exact content you've viewed and/or tested on another channel. Here are some examples:

  • Clone from a "QA" preview channel to the live channel of your site (going live!)

  • Clone from the live channel of your site to a "debug" preview channel (like before a rollback)

  • Clone from a channel in your "staging" Firebase project to a preview channel in your "prod" Firebase project

To clone a version, run the following command from any directory:

firebase hosting:clone SOURCE_SITE_ID:SOURCE_CHANNEL_ID TARGET_SITE_ID:TARGET_CHANNEL_ID

Replace each placeholder with the following:

  • SOURCE_SITE_ID and TARGET_SITE_ID: These are the IDs of the Hosting sites that contain the channels.

    • For your default Hosting site, use your Firebase project ID.
    • You can specify Hosting sites that are in the same Firebase project or even in different Firebase projects.
  • SOURCE_CHANNEL_ID and TARGET_CHANNEL_ID: These are the identifiers for the channels.

    • For a live channel, use live as the channel ID.
    • If the specified "target" channel doesn't yet exist, this command creates the channel before deploying to it.

Roll back to a previous version of your site

You can roll back to serve a previous version of your site's live channel. This action is useful if your current release has an issue and you want to roll back to serve a known working version of your site. Or perhaps your site served temporary content for a holiday or special event, but now you want to roll back to serve your "regular" content.

By rolling back, you create a new release that serves the same version of content as a previous release. In your Release history table, both releases will list the same version identifier.

Here's how to roll back:

  1. In the Firebase console, in the Release History table for your site, hover over the previous release entry that you want to roll back to.

  2. Click , then select Roll back.

Manually delete a release

You might need to manually delete a release from your live channel to free up Hosting storage for your project. You can only delete previous releases, not the release currently being served on your live site.

When you delete a release, you're actually deleting its content, which is scheduled for deletion within 24 hours. The release object itself is kept so that you can still see its metadata (who deployed and when they deployed).

Here's how to delete a release:

  1. In the Firebase console, in the Release History table for your site, hover over the previous release entry that you want to delete.

  2. Click , then select Delete.

Manually delete a preview channel

You can preview your channels by clicking on the channel you want to preview. From this view, you can see, delete, and revert the newest deployments and release that are tied to the specific channel. You can delete a preview channel, but you can't delete your site's live channel.

When you delete a preview channel, the channel, along with its releases and associated versions, are scheduled for deletion within 24 hours. The associated preview URL is also deactivated. An exception to the version-deletion is if a version is associated with another release (this happens, for example, if you clone a version from one channel to another within the same site).

Hosting supports two different ways to delete a preview channel:

  • Firebase console
    In the row for the preview channel, click , then select Delete channel. Confirm the deletion.

  • Firebase CLI
    Run the following command from any directory:

    firebase hosting:channel:delete CHANNEL_ID

CLI commands for preview channels and cloning

Commands for preview channels

All commands for preview channels support deploy targets if you have multiple Hosting sites.

Command Description
firebase hosting:channel:create CHANNEL_ID

Creates a new preview channel in the default Hosting site using the specified CHANNEL_ID

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 your Hosting content and config to the specified preview channel

If the preview channel does not yet exist, this command creates the channel in the default Hosting site before deploying to the channel.

firebase hosting:channel:list Lists all channels (including the "live" channel) in the default Hosting 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

Commands for version cloning

Command Description
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 VERSION_ID in the Hosting dashboard of the Firebase console.