More ways to deploy with Firebase App Hosting

App Hosting has more ways to deploy to fit your team’s development workflow, and supports automatic emulator configuration to make it easier to test your web app locally.

Last month, we launched Firebase App Hosting into General Availability (GA), a milestone that included new features to help you build faster and scale, and signalled that App Hosting is fully supported for production use.

We’re constantly improving App Hosting to make it easier for developers to build and deploy modern web apps. Since launching General Availability last month, we’ve added the ability to upload source code and container images directly to App Hosting (without using GitHub), giving you more flexibility in how you deploy to production. We also now have automatic configuration for the Firebase SDK in the emulator, so that when you run your app locally, it automatically uses emulated Firebase services instead of production.

More ways to deploy

Previously, the only way to deploy to App Hosting was through GitHub: you connect App Hosting to your GitHub repo and rollouts happen automatically when changes are pushed/merged into your live branch (such as main). While CI/CD is generally considered best practice, there are reasons you may not want to use App Hosting’s built-in Git integration. For example, you might want to integrate App Hosting deployments into your own custom CI/CD pipeline. Or maybe you’re early in your app development and haven’t yet set up continuous integration.

We now have three ways to deploy to App Hosting without using GitHub: Firebase Studio (launched at Cloud Next), firebase deploy with the Firebase CLI, and Terraform.

Deploy with Firebase Studio

If you create an app with Firebase Studio’s App Prototyping agent, you can deploy to Firebase App Hosting from Firebase Studio. This means you can upload source code directly from your workspace editor. If you have not already set up App Hosting, Firebase Studio walks you through a workflow to complete all the essential onboarding steps, from linking a Cloud Billing account to kicking off the first rollout of the app.

A screenshot of Firebase studio. There is a "Publish" button highlighted in the top right corner.
A screenshot of Firebase studio. There is a "Publish" button highlighted in the top right corner.

After deploying your app, App Hosting provides built-in monitoring within Firebase Studio, allowing you to easily check your app’s traffic and health without leaving your workspace.

A screenshot of Firebase studio with an App Hosting panel on the right side showing request stats for the deployed site
A screenshot of Firebase studio with an App Hosting panel on the right side showing request stats for the deployed site

Deploy from source with the Firebase CLI

The CLI command firebase deploy lets you push your app’s source code and configurations directly from your local machine to Firebase. This is especially convenient if you have other Firebase deployments (such as security rules or functions) and want to deploy your web app and backend services together with a single CLI command.

How it works:

Your first step is to run firebase init apphosting in your local project directory. This command walks you through setting up local source deployments for an App Hosting backend—either an existing backend or a new one.

$firebase init apphosting
Copied!

After initializing App Hosting, you’ll notice a new firebase.json file in your project. This file contains the information App Hosting needs to deploy your app with firebase deploy:

  • backendId: the backend to deploy to
  • rootDir: the root directory of your app
  • ignore: any files to ignore in the build

Then, run firebase deploy to upload your app’s source code and configuration files to App Hosting.

App Hosting uploads your source code to a Google Cloud Storage bucket, runs your framework build command in Cloud Build, and deploys the final artifacts to Cloud Run and Cloud CDN.

A screenshot of the App Hosting page of the Firebase console with a backend whose latest release status is "Deployed from the Firebase CLI" with a green check mark.
A screenshot of the App Hosting page of the Firebase console with a backend whose latest release status is "Deployed from the Firebase CLI" with a green check mark.

Deploy with Terraform

For even greater control over App Hosting deployments, Terraform provides a powerful ‘infrastructure-as-code’ solution. It allows you to define and manage your App Hosting resources using declarative configuration files. A key advantage of using Terraform is the ability to deploy your own pre-built container image directly to App Hosting, instead of relying on App Hosting to build from your source code. Key advantages of building your own container image include:

  • You have full control over the build process and deployed environment, including each image layer and all your app’s dependencies
  • Faster rollouts, because you’re doing the build before rolling out to App Hosting

Here’s an example of the google_firebase_app_hosting_build and google_firebase_app_hosting_backend resources:

app-hosting.tf
resource "google_firebase_app_hosting_build" "example" {
  project  = google_firebase_app_hosting_backend.example.project
  location = google_firebase_app_hosting_backend.example.location
  backend  = google_firebase_app_hosting_backend.example.backend_id
  build_id = "mini-build"

  source {
      container {
      image = "us-docker.pkg.dev/cloudrun/container/hello"
      }
  }
}

resource "google_firebase_app_hosting_backend" "example" {
  project = "my-project-name"
  # Choose the region closest to your users

  location         = "us-central1"
  backend_id       = "mini"
  app_id           = "1:0000000000:web:674cde32020e16fbce9dbd"
  serving_locality = "GLOBAL_ACCESS"
  service_account  = google_service_account.service_account.email

  depends_on = [google_project_service.fah]
}
Copied!

Visit Get started with Terraform and Firebase to learn more.

Automatic emulator configuration

Along with new ways to deploy, we’re introducing improvements to help you better test your app. If you are using the Firebase JavaScript SDK’s initializeApp without arguments to connect to Firebase services in your app (such as Auth or Realtime Database) and using the Firebase Local Emulator Suite to run your app locally, the App Hosting emulator now automatically uses the emulated versions of those services instead of production. This means you can safely test locally with peace of mind that you aren’t messing with production data.

init-firebase.js
// Use App Hosting's automatic initialization feature
const firebaseApp = initializeApp();

// Automatically connects to emulator locally, 
// or to your production db when deployed to App Hosting.
const db = getFirestore();
Copied!

Summary

Firebase App Hosting is significantly expanding its deployment options to cater to a wider array of developer workflows. Beyond the established GitHub integration, you now have flexibility to deploy directly from Firebase Studio, upload source code with the Firebase CLI, or leverage Terraform to roll out pre-built container images. These new pathways, coupled with improvements for local testing, empower developers to choose the deployment strategy that best fits their project needs, from rapid prototyping to sophisticated, custom CI/CD pipelines.

We hope that these new features will enhance your experience with App Hosting and we’re excited to see what you build!

If you haven’t already, head over to the Firebase console and explore our documentation to deploy your first app. As always, if you have questions, you can hit us up on any of our support channels, or post questions on Stack Overflow. And if you have ideas for any new features, let us know on User Voice.