# Firebase

> This page is about FlutterFlow (the app builder you use by describing your app), not FlutterFlow Studio.

URL: https://docs.flutterflow.io/ffx/firebase

Connect your own Firebase project, let the agent use it, and ask the agent to set up Firebase sign-in and a Firestore database in your app.

Use Firebase to build your app on your own Firebase project, with Firebase sign-in and a Firestore database. To connect an existing project with a key, the project needs a default Firestore database in Native mode and a service account with Firebase Admin access.

## Connect Firebase {#connect-firebase}

To connect your Firebase project to your app as a [connection](https://docs.flutterflow.io/ffx/glossary#backend-and-data):

1. Open **Project Settings › Connections**, and then turn on the switch for **Firebase**.
2. In the **Connect Firebase** dialog, choose how to connect:
   - **Set up with Google**: select **Create a new project**, or select **Use an existing project**, click **Choose with Google**, and then pick the project under **Existing Google Cloud project**. Choose a **Firestore location**, click **Connect**, and then allow the setup when Google asks. The setup doesn't link a billing account.
   - **Paste a service account key (JSON)**: paste the contents of your key's JSON file into **Service account key (JSON)**, and then click **Connect**. **Find it** opens the service accounts page in the Firebase console.

For more about connecting, see [Connect a service](https://docs.flutterflow.io/ffx/connect-a-service).

## Agent access {#agent-access}

The agent can't use your Firebase connection until an owner of your app allows it under **Agent access**, which is off by default. When it's on, the agent can read the project's settings, apps, security rules and indexes, and the documents in its Firestore database, which can include your app users' data. What the agent reads is sent to the AI model.

The agent can also register apps, turn on email sign-in, create indexes and replace the security rules. Only a thread that an owner started can make these changes, and each change waits for that owner's approval. An approved change applies to your Firebase project right away, not when you push, and can affect other apps that use the same project.

To allow the agent:

1. In **Project Settings › Connections**, click **Options** on the **Firebase** card, and then select **Settings**.
2. Under **Agent access**, click **Allow the agent**, and then click **Allow**.

To stop the agent, click **Turn off**. The agent stops at once, and changes that are waiting for approval don't run. Agent access also turns off when you replace the connection's key, until an owner allows it again.

## What to ask

After **Agent access** is on, click **Set up Firebase in my app** at the top of the Firebase page. A new thread opens with this request filled in, ready for you to send:

> Example request: "Set up Firebase sign-in (email and password) and a Firestore database in my app. Check the existing rules before changing them, and tell me what happens to existing users and data."

Your existing Firebase users and data stay where they are. Google sign-in is set up separately from Firebase sign-in.

## Agent questions {#what-the-agent-may-ask-you}

If Firebase isn't connected, the agent asks you to connect it in a **Connect** card above the message box. Before each change to your Firebase project, it asks under **Approval**, and you click **Approve** or **Decline**. See [Answer the agent](https://docs.flutterflow.io/ffx/answer-the-agent).

## Review {#check-the-result}

After the agent finishes, read the turn's [**Summary**](https://docs.flutterflow.io/ffx/what-changed#summary) and review its [**Changes**](https://docs.flutterflow.io/ffx/what-changed#changes-tab), and then try sign-in in **Preview**. The preview uses your real Firebase project, with its real users and data.

In the preview, email and password sign-in works, but social sign-in and email sign-in links don't finish.

## Push {#push-it}

When sign-in and your data work, [push the changes to your app](https://docs.flutterflow.io/ffx/push).

## Next steps

- To replace the key or disconnect Firebase, see [Manage connections](https://docs.flutterflow.io/ffx/manage-connections).
- For how keys are kept and when the agent asks first, see [How connections work](https://docs.flutterflow.io/ffx/connections).

## Troubleshooting {#if-something-goes-wrong}

For a refused key or a connection that needs attention, see [Troubleshoot connections](https://docs.flutterflow.io/ffx/troubleshoot-connections).
