Konsola git

Get started with Firebase Hosting

Firebase Hosting gives you a fast, secure, and reliable way to host your app's static assets (HTML, CSS, JavaScript, media files, etc.) as well as to serve 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 used with your own custom domain or on your project's free subdomains on web.app and firebaseapp.com.

Before you begin

Before you can set up Firebase Hosting, you need to create a Firebase project.

Step 1: Install the Firebase CLI

Visit the Firebase CLI documentation to learn how to install the CLI or update to its latest version.

Step 2: Initialize your project

To connect your local project to your Firebase project, run the following command from the root of your local project directory:

firebase init

During project initialization, from the Firebase CLI prompts:

  1. Select to set up Hosting.

    If you want to set up other Firebase products for your project, refer to their documentation for setup information. Note that you can always run firebase init later to set up more Firebase products.

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

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

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

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

    • The default for the public root directory is called public.

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

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

    • If you don't already have a valid index.html file or 404.html file in your public root directory, Firebase creates them for you.

  4. Choose a configuration for your site.

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

At the end of initialization, Firebase automatically creates and adds two files to 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 local project directory:

firebase deploy

This command deploys a release to your Firebase project's default Hosting sites:

  • projectID.web.app
  • projectID.firebaseapp.com

Learn more about deploys and even locally testing your site.

Next steps

Now your site is ready to share with the world! You can also learn how to:

Also, take a look at the full documentation for the Firebase CLI.