Get started with the App Prototyping agent

Firebase Studio includes a web-based interface that lets you rapidly prototype and generate AI-forward web apps using multimodal prompts, including natural language, images, and drawing tools. The agent supports Next.js apps, with other platforms and frameworks planned in the future.

The App Prototyping agent is a streamlined no-code development flow that uses generative AI to develop, test, iterate, and publish a full-stack, agentic web app. You describe your app idea in natural language with an optional image, and the agent generates an app blueprint, code, and a web preview. To assist in the development and publishing of your full-stack app, Firebase Studio can automatically provision the following services for you:

  • If your app uses AI: Firebase Studio adds the Gemini Developer API to your app, using the power of Genkit flows to work with Gemini. You can use your own Gemini API key or let Firebase Studio provision a Firebase project and Gemini API key for you.

  • If you want to publish your app to the web: Firebase Studio creates a project and provides a quick way to publish your app with Firebase App Hosting.

You can refine the app using natural language, images, and drawing tools, edit code directly, roll back changes, publish the app, and monitor its performance—all from Firebase Studio.

Get started

To get started with the App Prototyping agent, follow these steps:

  1. Log into your Google Account and open Firebase Studio.

  2. In the Prototype an app with AI field, describe your app idea in natural language.

    For example, you could enter a prompt like the following to create a recipe generation app:

    Use secure coding practices to create an error-free web app that lets
    users upload a photo or take a picture with their browser
    camera. The app identifies the food in the picture and generates a
    recipe and accompanying image that includes that food.
    
    If no food product is identified, generate a random dessert recipe.
    
  3. Optionally, upload an image to accompany your prompt. For example, you can upload an image that contains the color scheme you want your app to use and tell Firebase Studio to use it. Images must be less than 3 MiB.

  4. Click Prototype with AI.

    Gemini generates an app blueprint based on your prompt, returning a proposed app name, required features, and style guidelines.

  5. Review the blueprint. If necessary, make a few changes. For example, you could change the proposed app name or color scheme using one of these options:

    • Click Customize and edit the blueprint directly. Make your changes and click Save.

    • In the Describe... field in the chat pane, add clarifying questions and context. You can also upload additional images.

  6. Click Prototype this app.

  7. The App Prototyping agent begins coding your app.

    • If your app uses AI, you're prompted to add or generate a Gemini API key. If you click Auto-generate, the App Prototyping agent provisions a Firebase project and a Gemini API key for you.

Test, refine, debug, and iterate

After the initial app is generated, you can test, refine, debug, and iterate.

  • Review and interact with your app: After code generation completes, a preview of your app appears. You can interact with the preview directly to test it. Learn more at Preview your app.

  • Fix any errors as they occur: In most cases, the App Prototyping agent prompts you to fix any errors that arise. Click Fix Error to allow it to attempt a fix.

    If you receive errors that you're not prompted to fix automatically, copy the error and any relevant context (for example, "Can you fix this error in my Firebase initialization code?") into the chat window and send it to Gemini.

  • Test and iterate using natural language: Test your app thoroughly and work with the App Prototyping agent to iterate on the code and blueprint until you're happy with it.

    While in Prototyper mode, you can also use the following features:

    • Click Annotate icon Annotate to draw directly on the Preview window. Use the available shape, image, and text tools, along with an optional text prompt, to visually describe what you want the App Prototyping agent to change.

    • Click Select icon Select to select a specific element and enter instructions for the App Prototyping agent. This lets you quickly target a specific icon, button, piece of text, or other element. When you click an image, you also have the option of searching for and selecting a stock image from Unsplash.

    Optionally, you can click Link
icon Share preview link to share your app publicly and temporarily using Firebase Studio public previews.

  • Debug and iterate directly in the code: Click Code switch
icon Switch to Code to open Code view, where you can see all of your app's files and modify your code directly. You can switch back to Prototyper mode at any time.

    While in Code view, you can also use the following helpful features:

  • Test and measure your generative AI feature performance: You can use the Genkit Developer UI to run your Genkit AI flows, test, debug, interact with different models, refine your prompts, and more.

    To load your Genkit flows in the Genkit Developer UI and start testing:

    1. From the terminal in your Firebase Studio workspace, run the following command to source your Gemini API key and start the Genkit server:

       npm run genkit:watch
      
    2. Click the Genkit Developer UI link. The Genkit Developer UI opens in a new window with your flows, prompts, embedders, and a selection of different available models.

    Learn more about the Genkit Developer UI at Genkit Developer Tools.

Publish 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) 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 associated with the workspace. If it did not create a project during Gemini API key generation, it will create 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 . 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.

Secure your app with Firebase App Check and reCAPTCHA Enterprise

If you've integrated Firebase or Google Cloud services into your app, Firebase App Check helps protect your app backends from abuse by preventing unauthorized clients from accessing your Firebase resources. It works with both Google services (including Firebase and Google Cloud services) and your own custom backends to keep your resources safe.

We recommend adding App Check to any app you post publicly to protect your backend resources from abuse.

This section guides you through setting up App Check within Firebase Studio using reCAPTCHA Enterprise for a web app created by the App Prototyping agent, but you can set up App Check within any app that implements Firebase services and can implement custom providers. Learn more at Firebase App Check.

ReCAPTCHA Enterprise provides up to 10,000 assessments at no-cost.

Step 1: Set up reCAPTCHA Enterprise for your app

  1. Open the reCAPTCHA Enterprise section of the Google Cloud console.

  2. Select the name of your Firebase project from the Google Cloud console project picker.

  3. If you're prompted to enable the reCAPTCHA Enterprise API, do so.

  4. Click Get started, and add a Display name for your reCAPTCHA site key.

  5. Accept the default Web Application type key.

  6. Click Add a domain and add a domain. You'll want to add your App Hosting domain (for example, studio--PROJECT_ID.REGION.hosted.app) and any custom domains you use with or plan to use with your app.

  7. Click Next step.

  8. Leave Will you use challenges? unselected.

  9. Click Create key.

  10. Copy and save your Key ID and proceed to Configure App Check.

Step 2: Configure App Check

  1. Open the Firebase console and click Build > App Check from the navigation menu.

  2. Click Get started, then click Register next to your app.

  3. Click to expand ReCAPTCHA and paste the Key ID you generated for reCAPTCHA Enterprise.

  4. Click Save.

Step 3: Add App Check to your code

  1. Return to Firebase Studio and in Code view, add the site key you generated to your .env file:

    NEXT_PUBLIC_RECAPTCHA_SITE_KEY=RECAPTCHA_SITE_KEY
    
  2. If you don't already have your Firebase configuration saved to .env, obtain it:

    • From the Firebase console, open Project settings and locate it within your the section that corresponds with your app.

    • From the Terminal in Code view:

      1. Log into Firebase: firebase auth login
      2. Select your project: firebase use FIREBASE_PROJECT_ID
      3. Obtain the Firebase config: firebase apps:sdkconfig
  3. Add the configuration to your .env file so that it looks like the following:

    NEXT_PUBLIC_FIREBASE_API_KEY=FIREBASE_API_KEY
    NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=FIREBASE_AUTH_DOMAIN
    NEXT_PUBLIC_FIREBASE_PROJECT_ID=FIREBASE_PROJECT_ID
    NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=FIREBASE_STORAGE_BUCKET
    NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=FIREBASE_MESSAGING_SENDER_ID
    NEXT_PUBLIC_FIREBASE_APP_ID=FIREBASE_APP_ID
    NEXT_PUBLIC_RECAPTCHA_SITE_KEY=RECAPTCHA_SITE_KEY
    
  4. Add App Check to your app code. You can ask Gemini to add App Check with reCAPTCHA Enterprise to your app (be sure to specify "reCAPTCHA Enterprise" and be sure to double-check it!), or follow the steps in Initialize App Check.

  5. Re-publish your site to App Hosting. Try testing your Firebase features to generate some data.

  6. Verify that App Check is receiving requests in the Firebase console by opening Build > App Check.

  7. Click to inspect Firebase services. After verifying that requests are arriving, click Enforce to enforce App Check.

  8. Repeat verification and enforcement for Firebase Authentication.

If, after you have registered your app for App Check, you want to run your app in an environment that App Check would normally not classify as valid, such as locally during development, or from a continuous integration (CI) environment, you can create a debug build of your app that uses the App Check debug provider instead of a real attestation provider. Learn more at Use App Check with the debug provider in web apps.

Monitor your app

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:

  • Click Publish to release a new version of your app.
  • Share the link to your app or open your app directly in Visit your app.
  • Review a summary of your app's performance over the last 7 days, including the total number of requests and the status of your latest rollout. Click View details to access even more information in the Firebase console.
  • View a graph of the number of the number of requests your app has received over the last 24 hours, broken down by HTTP status code.

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 deployment

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.

  • To roll back a published site:

    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.

  • To remove your App Hosting domain from the web:

    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.

Use Genkit Monitoring for your deployed features

You can monitor your Genkit feature steps, inputs, and outputs by enabling telemetry to your AI flow code. Genkit's telemetry feature lets you monitor the performance and usage of your AI flows. This data can help you identify areas for improvement, troubleshoot issues, optimize your prompts and flows for better performance and cost efficiency, and track the usage of your flows over time.

To set up monitoring in Genkit, you add telemetry to the Genkit AI flows and then view the results in the Firebase console.

Step 1: Add telemetry to your Genkit flow code in Firebase Studio

To set up monitoring in your code:

  1. If you aren't already in Code view, click Code switch
icon Switch to Code to open it.

  2. Check package.json to verify the version of Genkit that's installed.

  3. Open the terminal (Ctrl-Shift-C, or Cmd-Shift-C in MacOS).

  4. Click inside the terminal and install the Firebase plugin, using the version that matches your package.json file. For example, if the Genkit packages in your package.json are at 1.0.4, you should run the following command to install the plugin:

    npm i --save @genkit-ai/firebase@1.0.4
  5. From Explorer, expand src > ai > flows. One or more TypeScript files that contain your Genkit flows appear in the flows folder.

  6. Click one of the flows to open it.

  7. At the bottom of the imports section of the file, add the following to import and enable FirebaseTelemetry:

    import { enableFirebaseTelemetry } from '@genkit-ai/firebase';
    
    enableFirebaseTelemetry();
    

Step 2: Set up permissions

Firebase Studio enabled the required APIs for you when it set up your Firebase project, but you also need to provide permissions to the App Hosting service account.

To set up permissions:

  1. Open the Google Cloud IAM console select your project, then grant the following roles to the App Hosting service account:

    • Monitoring Metric Writer (roles/monitoring.metricWriter)
    • Cloud Trace Agent (roles/cloudtrace.agent)
    • Logs Writer (roles/logging.logWriter)
  2. Re-publish your app to App Hosting.

  3. When publishing is complete, load your app and start using it. After five minutes, your app should start logging telemetry data.

Step 3: Monitor your generative AI features on the Firebase console

When telemetry is configured, Genkit records the number of requests, success, and latency for all of your flows, and, for each specific flow, Genkit collects stability metrics, shows detailed graphs, and logs captured traces.

To monitor your AI features implemented with Genkit:

  1. After five minutes, open Genkit in the Firebase console and review Genkit's prompts and responses.

    Genkit compiles the following Stability metrics:

    • Total requests: The total number of requests received by your flow.
    • Success rate: The percentage of requests that were successfully processed.
    • 95th percentile latency: The 95th percentile latency of your flow, which is the time it takes for 95% of requests to be processed.
    • Token usage:

      • Input tokens: The number of tokens sent to the model in the prompt.
      • Output tokens: The number of tokens generated by the model in the response.
    • Image usage:

      • Input images: The number of images sent to the model in the prompt.
      • Output images: The number of images generated by the model in the response.

    If you expand stability metrics, detailed graphs are available:

    • Request volume over time.
    • Success rate over time.
    • Input and output tokens over time.
    • Latency (95th and 50th percentile) over time.

Learn more about Genkit at Genkit.

Next steps