Deploy targets

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:

  1. Apply aTARGET_NAME to the targeted Firebaseresource or group of Firebase resources.
  2. In yourfirebase.json file,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.

Note: TheFirebase CLI applies deploy targets to the Firebase resources inthecurrently active Firebase project in the CLI. So, if you'remanaging multiple Firebase projectswith the CLI, configure the deploy targets for each Firebase project.

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:

Note: Run allFirebase CLI commands for deploy targets from the root of yourproject directory.

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, usehosting.
  • TARGET_NAME — a unique name for theHosting site that you'redeploying to

  • RESOURCE_IDENTIFIER — theSITE_ID for 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, usestorage.
    • ForRealtime Database instances, usedatabase.
  • 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:

  1. Create an array of configuration objects for each Firebase resourceTYPE(hosting,storage, ordatabase).
  2. In the arrays, specify thetarget (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.

CommandDescription
firebase targetLists the deploy targets for your current project directory
firebase target:remove \
TYPERESOURCE_IDENTIFIER
Removes a resource from the target to which it's been assigned
firebase target:clear \
TYPETARGET_NAME
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.

CommandDescription
firebase emulators:startEmulatesall the configured resources in your project directory
firebase emulators:start \
--only hosting:TARGET_NAME
Emulates only theHosting content and configuration of the specifiedHosting site
firebase emulators:start \
--only storage:TARGET_NAME
Emulates only the rules file for the specifiedCloud Storage target
firebase emulators:start \
--only database:TARGET_NAME
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.

CommandDescription
firebase deployCreates a release ofall deployable resources in your project directory
firebase deploy \
--only hosting:TARGET_NAME
Deploys only theHosting content and configuration of the specifiedHosting site to the live channel for the site
firebase hosting:channel:deployCHANNEL_ID \
--onlyTARGET_NAME
Deploys only theHosting content and configuration of the specifiedHosting site to apreview channel for the site
firebase deploy \
--only storage:TARGET_NAME
Deploys only the rules file for the specifiedCloud Storage target
firebase deploy \
--only database:TARGET_NAME
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.