Deploy targets Stay organized with collections Save and categorize content based on your preferences.
Deploy targets are short-name identifiers (that you define yourself) forFirebase resources in your Firebase project, like aHosting site with uniquestatic assets or a group ofRealtime Database instances that share the same securityrules.
Deploy targets are useful when you havemultipleHosting sites,multipleCloud Storage buckets, ormultipleRealtime Database instances.With deploy targets, theFirebase CLI can deploy settings to aspecificFirebase resource or group of resources in your project, such as:
- The hosting configuration for each of yourHosting sites
- Static assets from your project directory for each of yourHostingsites
- Security rules shared by multipleRealtime Database instances or multipleCloud Storage buckets
To set up a deploy target:
- Apply a
TARGET_NAMEto the targeted Firebaseresource or group of Firebase resources. - In your
firebase.jsonfile,reference the associatedTARGET_NAMEwhen you're configuring the settings for each resource or group of resources.
When you runFirebase CLI commands (likefirebase deploy), theFirebase CLI pairs eachTARGET_NAME with itsassociated Firebase resources. The CLI then communicates to your Firebaseproject the settings for each resource.
Set up deploy targets for your Firebase resources
Using theFirebase CLI, apply aTARGET_NAME (short-name identifier thatyou define yourself) to a Firebase resource or group of Firebase resources.Firebase supports deploy targets for:
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.
Set up deploy targets forHosting
To create a deploy target and apply aTARGET_NAME to aHosting site, runthe following CLI command:
firebase target:applyTYPETARGET_NAMERESOURCE_IDENTIFIER
Where the parameters are:
TYPE — the relevant Firebase resource type
- ForFirebase Hosting sites, use
hosting.
- ForFirebase Hosting sites, use
TARGET_NAME — a unique name for theHosting site that you'redeploying to
RESOURCE_IDENTIFIER — the
SITE_IDfor theHosting siteaslisted in your Firebase project
For example, if you'vecreated two sites(myapp-blog andmyapp-app) in your Firebase project, you could apply auniqueTARGET_NAME (blog andapp, respectively) to each site by runningthe following commands:
firebase target:applyhosting blog myapp-blog
firebase target:applyhosting app myapp-app
Set up deploy targets forCloud Storage orRealtime Database
To create a deploy target and apply aTARGET_NAME to a set ofCloud Storage orRealtime Database resources, run the following CLIcommand:
firebase target:applyTYPETARGET_NAMERESOURCE-1_IDENTIFIERRESOURCE-2_IDENTIFIER ...
Where the parameters are:
TYPE — the relevant Firebase resource type
- ForCloud Storage buckets, use
storage. - ForRealtime Database instances, use
database.
- ForCloud Storage buckets, use
TARGET_NAME — a unique name for the resource or group of resourcesthat share security rules
RESOURCE_IDENTIFIER — the identifiers for the resourcesaslisted in your Firebase project (like storage bucket names or databaseinstance IDs) that all share the same security rules
For example, you could apply theTARGET_NAME ofmain to a group of threeregionalCloud Storage buckets (that all share the same security rules)by running the following command:
firebase target:applystorage main myproject.firebasestorage.app myproject-eu myproject-ja
Note thatmyproject.firebasestorage.app is the identifier for thedefault bucket, whilemyproject-eu andmyproject-ja are two additionalbuckets created in the Firebase project.
Configure your firebase.json file to use deploy targets
After you've set up deploy targets for your Firebase resources, reference eachappliedTARGET_NAME in yourfirebase.json configuration file:
- Create an array of configuration objects for each Firebase resource
TYPE(hosting,storage, ordatabase). - In the arrays, specify the
target(using theTARGET_NAME) and defineyour settings for the associated Firebase resource or group of resources.
Continuing the examples from above, where your Firebase project has twoHosting sites and threeCloud Storage buckets (that share the samesecurity rules), yourfirebase.json file would look like this:
{ "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 } ]}{ "storage": [ {"target": "main", // "main" is the applied TARGET_NAME for the group ofCloud Storage buckets "rules": "storage.main.rules" // the file that contains the shared security rules } ]}If you have multiple configurations for your resources, you can create multipledeploy targets and specify each one in thefirebase.json file. All associatedresources will be deployed together when you runfirebase deploy.
Manage deploy targets
The settings for deploy targets are stored in the.firebaserc file in yourproject directory. You can manage your project's deploy targets by running anyof the following commands from the root of your project directory.
| Command | Description |
|---|---|
firebase target | Lists the deploy targets for your current project directory |
firebase target:remove \ | Removes a resource from the target to which it's been assigned |
firebase target:clear \ | Removes all the resources orHosting site from the specified target |
Thetarget:remove andtarget:clear commands automatically update the deploytarget settings in the.firebaserc file in your project directory.
Test locally before deploying
Run any of the following commands from the root of your project directory.
| Command | Description |
|---|---|
firebase emulators:start | Emulatesall the configured resources in your project directory |
firebase emulators:start \ | Emulates only theHosting content and configuration of the specifiedHosting site |
firebase emulators:start \ | Emulates only the rules file for the specifiedCloud Storage target |
firebase emulators:start \ | Emulates only the rules file for the specifiedRealtime Database target |
Learn more about configuring and using theFirebase Local Emulator Suite.
Deploy specific Firebase resources
Run any of the following commands from the root of your project directory.
| Command | Description |
|---|---|
firebase deploy | Creates a release ofall deployable resources in your project directory |
firebase deploy \ | Deploys only theHosting content and configuration of the specifiedHosting site to the live channel for the site |
firebase hosting:channel:deployCHANNEL_ID \ | Deploys only theHosting content and configuration of the specifiedHosting site to apreview channel for the site |
firebase deploy \ | Deploys only the rules file for the specifiedCloud Storage target |
firebase deploy \ | Deploys only the rules file for the specifiedRealtime Database target |
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-03 UTC.