Get started with Firebase Hosting Stay organized with collections Save and categorize content based on your preferences.
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:
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.
Specify a directory to use as your public root directory.
This directory contains all your publicly served static files, including your
index.htmlfile and any other assets that you want to deploy toFirebase Hosting.The default for the public root directory is called
public.You can specify your public root directory now or you canspecify it later in your
firebase.jsonconfiguration 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.htmlfile or404.htmlfile inyour public root directory, Firebase creates them for you.
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:
A
firebase.jsonconfiguration file that lists your project configuration.Learn more about this file on theconfigure hosting behavior page.A
.firebasercfile that stores yourproject aliases.
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
--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.appPROJECT_ID.firebaseapp.com
Learn more aboutdeploys and even locally testing your site.
Next steps
Now your site is ready to share with the world!
Continue to improve your site. Test locally, share changes at a temporarypreview URL, then deploy to your live site. Follow thisstep-by-step guide.
Learn about further hosting capabilities:
Take a look at the full documentation for theFirebase CLI.
Prepare to launch your app:
- Set upbudgetalertsfor your project in theGoogle Cloud console.
- Monitor theUsage and billingdashboard in theFirebase console to get an overall picture of your project'susage across multiple Firebase services.You can also visit theHostingUsagedashboard for moredetailed usage information.
- Review theFirebase launch checklist.
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.