Get started with Firebase Hosting

Firebase Hosting gives you a fast, secure, and reliable way to host yourapp's static assets (HTML, CSS, JavaScript, media files, etc.) as well as toserve dynamic content and host microservices.

Our production-grade hosting is backed by a global content delivery network(CDN).Hosting serves your content over SSL, by default, and can be usedwith your owncustom domain or on your project'ssubdomains at no cost onweb.app andfirebaseapp.com.

Before you begin

Before you can set upFirebase Hosting, you need tocreate a Firebase project.

Step 1: Install theFirebase CLI

Visit theFirebase CLI documentation to learn how toinstall the CLI orupdate to its latest version.

Note: You can also runFirebase CLI commands inCloud Shell.Cloud Shell is abrowser-based, pre-authenticated command-line environment, accessible from theFirebase console,and comes with theFirebase CLI pre-installed. This makes it a convenient option for gettingstarted quickly, provided you add your project files to theCloud Shell environment.

Step 2: Initialize your project

To connect your local project files to your Firebase project, run the followingcommand from the root of your local project directory:

firebase init hosting

During project initialization, from theFirebase CLI prompts:

  1. Select a Firebase project to connect to your local project directory.

    The selected Firebase project is your "default" Firebase project for yourlocal project directory. To connect additional Firebase projects to yourlocal project directory, set upproject aliases.

  2. Specify a directory to use as your public root directory.

    This directory contains all your publicly served static files, including yourindex.html file and any other assets that you want to deploy toFirebase Hosting.

    • The default for the public root directory is calledpublic.

      • You can specify your public root directory now or you canspecify it later in yourfirebase.json configuration file.

      • If you select the default and don't already have a directory calledpublic, Firebase creates it for you.

    • If you don't already have a validindex.html file or404.html file inyour public root directory, Firebase creates them for you.

  3. Choose a configuration for your site.

    If you select to make a one-page app, then Firebase automatically addsrewrite configurations for you.

At the end of initialization, Firebase automatically creates and adds two filesto the root of your local app directory:

Step 3: Deploy to your site

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

firebase deploy --only hosting
Note: By running this command with the--only hosting flag, you're onlydeploying yourHosting content and config. If youalso want todeploy other project resources or configurations(like functions or database rules), run this command with a comma-separatedlist in the flag (for example,--only hosting,functions).

This command deploys yourHosting content and config to the followingFirebase-provisioned subdomains:

  • PROJECT_ID.web.app
  • PROJECT_ID.firebaseapp.com

Learn more aboutdeploys and even locally testing your site.

Next steps

Now your site is ready to share with the world!

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-05 UTC.