Share project resources across multiple sites Stay organized with collections Save and categorize content based on your preferences.
You can set up one or moreFirebase Hosting sites in a single Firebaseproject. Since the sites are all in the same Firebase project, all the sites canaccess the other Firebase resources of the project.
- Each site has its ownhosting configuration.
- Each site hosts its own collection of content.
- Each site can have one or moreassociated domains.
By setting up multipleHosting sites within the same Firebase project, youcan more easily share Firebase resources between related sites and apps. Forexample, if you set up your blog, admin panel, and public app as individualsites in the same Firebase project, they can all share the sameFirebase Authentication user database, while also having their own unique domains orcontent.
Important: To mirror your workflow environments (for example, Dev, Q1, Q2,Prod), we recommend that you create a separate Firebase project for eachenvironment rather than creating multiple sites in a single Firebase project.Generally, you don't want to use production-environment Firebase resources (likecustomer data in aRealtime Database) in a development environment. Consider usingautomatic SDK configurationto mirror multiple environments using a single codebase.The multisite feature supports a maximum of 36 sites per Firebase project.Step 1: Update yourFirebase CLI version
Access the most currentFirebase Hosting features byupdating to the latest version of theFirebase CLI.
Step 2: Add additional sites
Add additional sites to a Firebase project using one of the following methods:
Use the workflow in theHosting page of theFirebase console
Use theFirebase CLI command:
firebase hosting:sites:createSITE_IDUse theHosting REST API:
projects.sites.create
For each of these methods, you'll specify aSITE_ID which is used to constructthe Firebase-provisioned default subdomains for the site:
SITE_ID.web.appSITE_ID.firebaseapp.com
Because theSITE_ID is used for these URLs, the site ID has the followingrequirements:
- Must be a valid hostname label, meaning it cannot contain
.,_, etc. - Must be 30 characters or fewer
- Must be globally unique within Firebase
To each site, you can also optionallyadd custom domains to serve the same content andconfiguration to multiple URLs.
Note: If you created multipleFirebase Realtime Database instances in your Firebaseproject before August 2018, Firebase automatically provisioned a correspondingsite for each database instance. If you don't need these additional sites, youcan delete them without affecting your database instances.Delete a secondary site
Delete unwanted sites from a Firebase project using one of the followingmethods:
Use the workflow in theHosting page of theFirebase console
Use theFirebase CLI command:
firebase hosting:sites:deleteSITE_IDUse theHosting REST API:
projects.sites.delete
Note that you cannot delete the default site, which has the sameSITE_ID asyour Firebase project ID.
SITE_ID cannot be reactivated by you or anyone else.Step 3: Set up deploy targets for your sites
When you have multiple sites and you runFirebase CLI deploy commands, theCLI needs a way to communicate which settings should be deployed to eachsite. Withdeploy targets you can uniquely identifyaspecific site with aTARGET_NAME in yourfirebase.json configuration fileand in yourFirebase CLI commands fortesting or deploying to your sites.
If you previously configured your
firebase.json file by explicitly referencing yourSITE_ID, you should edit yourfirebase.json configuration and yourCLI commands to use deploy targets instead.To create a deploy target and apply aTARGET_NAME to aHosting site, runthe following CLI command from the root of your project directory:
firebase target:apply hostingTARGET_NAMERESOURCE_IDENTIFIER
Where the parameters are:
TARGET_NAME — a unique name (that you've defined yourself) for theHosting site that you're deploying to
RESOURCE_IDENTIFIER — the
SITE_IDfor theHosting siteaslisted in your Firebase project
For example, if you've created two sites (myapp-blog andmyapp-app) in yourFirebase project, you could apply a uniqueTARGET_NAME (blogandapp, respectively) to each site by running the following commands:
firebase target:apply hostingblog myapp-blog
firebase target:apply hostingapp myapp-app
The settings for deploy targets are stored in the.firebaserc file in yourproject directory, so you only need to set up deploy targets one time perproject.
Step 4: Define the hosting configuration for each site
Use a site's appliedTARGET_NAME when you're defining its hostingconfiguration in yourfirebase.json file.
If your
firebase.jsonfile defines the configuration for multiple sites,use an array format:{ "hosting": [ {"target": "blog", // "blog" is the applied TARGET_NAME for theHosting site "myapp-blog" "public": "blog/dist", // contents of this folder are deployed to the site "myapp-blog" // ... }, {"target": "app", // "app" is the applied TARGET_NAME for theHosting site "myapp-app" "public": "app/dist", // contents of this folder are deployed to the site "myapp-app" // ... "rewrites": [...] // You can define specificHosting configurations for each site } ]}If your
firebase.jsonfile defines the configuration for only one site,it's not necessary to use an array format:{ "hosting": {"target": "blog", "public": "dist", // ... "rewrites": [...] }}
Step 5: Test locally, preview changes, and deploy to your sites
Run any of the following commands from the root of your local project directory.
| Command | Description |
|---|---|
firebase emulators:start --only hosting | Emulates theHosting content and configuration of thedefaultHosting site at a locally hosted URL |
firebase emulators:start --only hosting:TARGET_NAME | Emulates theHosting content and configuration of the specifiedHosting site at a locally hosted URL |
firebase hosting:channel:deploy \ | Deploys theHosting content and configuration of thedefaultHosting site at a preview URL |
firebase hosting:channel:deploy \ | Deploys theHosting content and configuration of the specifiedHosting site at a preview URL |
firebase deploy --only hosting | Deploys theHosting content and configuration to the live channel ofallHosting sites configured infirebase.json |
firebase deploy --only hosting:TARGET_NAME | Deploys theHosting content and configuration to the live channel of the specifiedHosting site |
| Command | Description |
|---|---|
(not recommended; useemulators:start instead)firebase serve --only hosting | Serves theHosting content and configuration of thedefaultHosting site at a locally hosted URL |
(not recommended; useemulators:start instead)firebase serve --only hosting:TARGET_NAME | Serves theHosting content and configuration of the specifiedHosting site at a locally hosted URL |
--only hosting flag, you're only emulating or deploying yourHosting content and config. If youalso want to emulate or deployother project resources or configurations (like functions or database rules), run commands with a comma-separated list in the flag (for example,--only hosting,functions).For deploys to preview channels, you don't specifyhosting in the--only flag because those commands canonly deploy yourHosting content and config.
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.