Publish your app with Firebase Studio

Publish your app with Firebase Studio

Firebase Studio offers multiple publishing options, allowing you to choose the method that best suits your project's needs. Here's an overview of the available options:

If you developed a Next.js app with the App Prototyping agent, you can publish directly from Firebase Studio in just a few clicks.

If you developed a static or single-page web app in Firebase Studio, you can publish directly from Firebase Studio by prompting Gemini to publish your app.

Publish and monitor your app with Firebase App Hosting

After you've tested your app and are satisfied with it in your workspace, you can publish it to the web with Firebase App Hosting.

When you set up App Hosting, Firebase Studio creates a Firebase project for you (if one was not already created by auto-generating a Gemini API key or other backend services) and guides you through linking a Cloud Billing account.

To publish your app:

  1. Click Publish to set up your Firebase project and publish your app. The Publish your app pane appears.
  2. In the Firebase project step, the App Prototyping agent displays the Firebase project associated with the workspace. If a Firebase project doesn't already exist, the App Prototyping agent creates a new project for you. Click Next to proceed.
  3. In the Link Cloud Billing account step, choose one of the following:
    • Select the Cloud Billing account that you want to link to your Firebase project.
    • If you don't have a Cloud Billing account or want to create a new one, click Create a Cloud Billing account. This opens the Google Cloud console, where you can create a new self-serve Cloud Billing account. After you create the account, return to Firebase Studio and select the account from the Link Cloud Billing list.
  4. Click Next. Firebase Studio links the billing account to the project associated with your workspace, created either when you auto-generated a Gemini API key or when you clicked Publish.
  5. Click Set up services. The App Prototyping agent begins provisioning Firebase services.
  6. Click Publish now. Firebase Studio sets up Firebase services and then launches the App Hosting rollout. This can take up to several minutes to complete. To learn more about what's happening behind the scenes, see The App Hosting build process.
  7. When the publish step completes, the App overview appears with a URL and app insights powered by App Hosting observability. To use a custom domain (like example.com or app.example.com) instead of the Firebase-generated domain, you can add a custom domain in the Firebase console.

For more information about App Hosting, see Understand App Hosting and how it works.

(Cloud Firestore only) Add indexes and verify security rules in production

When publishing is complete and your app is deployed to Firebase, Cloud Firestore and Firebase Authentication are ready to test in production.

Generate indexes for your Cloud Firestore database

When you deploy your app to Cloud Firestore, indexes are not generated automatically. This means that, after you publish, you may need to generate indexes for your queries.

You may see this surfaced in error messages or in your browser's Developer console.

To generate indexes after publishing:

  1. From a published app: In the App overview pane (click Publish if it's not visible), locate and click the Visit your app link.
  2. From the Firebase Studio preview: Open your browser's Developer console and locate the error 200 message that Cloud Firestore generates.
  3. Test all flows within your app. An error may appear that says something like, "Error loading recipes. The query requires an index. You can create it here:" with a link to the Firebase console.
  4. Follow the link to navigate to the Firebase console and a recommended index appears.
  5. Click Save to accept the recommended index.
  6. Return to your app and reload the page.
  7. Continue testing all flows in your app to add indexes where necessary.

Learn more at Manage indexes in Cloud Firestore.

View Cloud Firestore and Firebase Authentication data in the Firebase console

You can view live data from your app in the Firebase console after publishing.

Test Cloud Firestore rules in production

After publishing your app, you should test your Cloud Firestore security rules again, against your production environment. This helps to ensure that your data is accessible to authorized users and protected from unauthorized access.

You can test your rules using all of the following methods:

Monitor your app with App Hosting observability

The App overview panel in Firebase Studio provides key metrics and information about your app, letting you monitor your web app's performance using App Hosting's built-in observability tools. After your site rolls out, you can access the overview by clicking Publish. From this panel, you can:

If you close the App overview panel, you can re-open it at any time by clicking Publish.

Learn more about managing and monitoring App Hosting rollouts at Manage rollouts and releases.

Roll back your App Hosting site

If you've deployed successive versions of your app to App Hosting, you can roll it back to one of the earlier versions. You can also remove it.

  1. Open App Hosting in the Firebase console.
  2. Locate your app's backend, click View, and then click Rollouts.
  3. Next to the deployment you want to roll back to, click More, then choose Roll back to this build, and confirm.

Learn more at Manage rollouts and releases.

  1. From the Firebase console, open App Hosting, and click View in the Firebase Studio app section.
  2. In the Backend information section, click Manage. The Domains page loads.
  3. Next to your domain, click More, then choose Disable domain, and confirm.

This removes your domain from the web. To fully remove your App Hosting backend, follow the instructions in Delete a backend.

Firebase Hosting

You can publish static and single-page web apps to Firebase Hosting from your Firebase Studio workspace.

If you don't have the required Firebase project permissions, ask a Firebase project Owner to assign you the applicable role in the Firebase console Users and Permissions page. If you have questions about accessing your Firebase project, including finding or assigning an Owner, see Permissions and access to Firebase projects.

Publish with assistance from Gemini

  1. In the chat with Gemini, enter a prompt such as "Publish my app."
  2. Gemini guides you through the necessary steps. This may include creating a Firebase project and registering your app if you haven't done so already.

Publish from the Firebase Studio panel

Firebase Hosting is optimized for static sites and single-page applications. If your project has dynamic content, Gemini might not initiate the publishing flow. If this happens but you still want to use Firebase Hosting, publish your project from the Firebase Studio panel:

  1. If you haven't done so already, create a Firebase project and register your app.
  2. Open your Firebase Studio workspace. If you're using the App Prototyping agent, click Switch to Code to open Code view.
  3. In the navigation pane, click the Firebase Studio icon to open the panel, then expand the Firebase Hosting section.
  4. Click Authenticate Firebase and follow the prompts in the Terminal window to authenticate your Firebase account.
  5. Click Initialize Firebase Hosting and follow the prompts in the Terminal window to set up your deployment configuration.
  6. To deploy your app, click either Deploy to Production or Deploy to Channel from the Firebase Hosting section of the Firebase Studio panel.

Cloud Run

Before you deploy using Cloud Run, make sure you set up a Google Cloud project and enable Cloud Billing.

  1. Open your Firebase Studio workspace. If you're using the App Prototyping agent, click Switch to Code to open Code view.
  2. Click the Firebase Studio icon in the navigation pane to open the Firebase Studio panel and click Deploy to Cloud Run.
  3. Select Allow this workspace to access Google Cloud resources using my Google Account and then select a Google Cloud project with billing enabled from the dialog windows.
  4. Click Authenticate from the Cloud Run section of the Firebase Studio panel and follow the prompts to authenticate.
  5. Click Deploy and follow the prompts to set up your deployment configuration and deploy your app.

Next steps