Google is committed to advancing racial equity for Black communities. See how.

Test locally then deploy to your site

You can view and test your site locally, even emulate your HTTPS functions, before deploying your site to production.

Get started

Complete the steps listed on the Hosting Get Started page, which include installing the Firebase CLI and connecting your local project to your Firebase project.

Serve and test your Firebase project locally (optional)

You can view and test your Firebase project on locally hosted URLs before deploying to production. If you only want to test select features, you can use a comma-separated list in a flag on the firebase serve command.

Run the following command from the root of your local project directory if you want to do either of the following tasks:

firebase serve --only hosting

Emulate your project using local HTTP functions

Run any of the following commands from your project directory to emulate your project using local HTTP functions.

  • To emulate HTTP functions and hosting for testing on local URLs, use either of the following commands:

    firebase serve
    firebase serve --only functions,hosting // uses a flag
  • To emulate HTTP functions only, use the following command:

    firebase serve --only functions

Test from other local devices

By default, firebase serve only responds to requests from localhost. This means that you'll be able to access your hosted content from your computer's web browser but not from other devices on your network. If you'd like to test from other local devices, use the --host flag, like so:

firebase serve --host  // accepts requests to any host

Deploy to your site

To deploy to your site, run the following command from the root of your local project directory:

firebase deploy

This command deploys a release to the following sites:

  • Your Firebase project's default Hosting sites, and

  • Any custom domains that you've connected to your Hosting site.

You can optionally add a comment to a deploy. This comment will display with the other deployment information on your project's Hosting page. For example:

firebase deploy -m "Deploying the best new feature ever."

Deploys for projects with multiple sites

If you've added additional sites to your Firebase project, use the following command to deploy to one of those sites:

firebase deploy --only hosting:TARGET_NAME

The TARGET_NAME parameter is the unique identifier that you specified for the additional Hosting site during its setup.

Add predeploy and postdeploy scripted tasks

You can optionally connect shell scripts to the firebase deploy command to perform predeploy or postdeploy tasks. For example, a postdeploy hook could notify administrators of new site content deploys. Refer to the Firebase CLI documentation for more details.

Caching deployed content

When a request is made for static content, Firebase Hosting automatically caches the content on the CDN. If you redeploy your site's content, Firebase automatically clears all your cached static content across the CDN so that new requests receive your new content.

Note that you can configure the caching of dynamic content.

Serving over HTTPS

As you're developing your application, make sure that all external resources that are not hosted on Firebase Hosting are loaded over SSL (HTTPS), including any external scripts. Most browsers do not allow users to load "mixed content" (SSL and non-SSL traffic).