Skip to main content

Connect to Firebase

Firebase is a Google platform for building apps, with Firestore and Realtime Database as its two main data stores, plus a built-in Authentication service.

What you can do with Firebase in Retool

After you create a Firebase resource in Retool, you can:

  • Query, insert, update, and delete Firestore documents and collections.
  • Read, write, and update Realtime Database references.
  • List, retrieve, create, update, and delete Firebase Authentication users.
  • Build admin panels and CRUD apps on top of Firebase data.

Before you begin

To connect Firebase to Retool, you need the following:

  • Firebase service account: A Google Cloud service account key with access to your Firebase project.
  • Firebase database URL: Required if you plan to query Realtime Database.
  • Retool permissions: Ability to create and manage resources in your organization.

Create a Firebase resource

Follow these steps to create a Firebase resource in Retool.

Create a new resource

In your Retool organization, navigate to Resources in the main navigation and click Create newResource. Search for Firebase and click the Firebase tile to begin configuration.

Firebase resource configuration form.

Configure general settings

Specify a name and description for the resource that indicates which Firebase project it connects to. The description provides more context to users and Assist about how to use the resource.

Example nameExample description
Firebase (Production)Production Firebase project used for the customer-facing mobile app.
Firebase (Admin panel)Firebase project used to power an internal admin panel.

Configure authentication

Firebase authenticates using a Google Cloud service account.

Service account key

Paste the JSON key for a Google Cloud service account with access to your Firebase project. Refer to Firebase's documentation to generate a service account key.

Example
{
"type": "service_account",
"project_id": "example-project",
"private_key_id": "abc123",
"private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n",
"client_email": "firebase-adminsdk@example-project.iam.gserviceaccount.com",
"client_id": "123456789",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token"
}

Firebase database URL

The URL of your Firebase Realtime Database instance. Only required if you plan to query Realtime Database. Refer to Firebase's documentation to find your database URL.

Example
https://example-project-default-rtdb.firebaseio.com

Configure advanced options

Configure optional settings available under the Advanced options section of the resource configuration form.

Outbound region

If your organization uses outbound regions, select the region that should be used for requests to Firebase. This controls which geographic region your requests originate from.

Test the connection

Click Test connection to verify Retool can connect to your Firebase project. If the test succeeds, you see a success message. If it fails, check the following:

  • Service account permissions: Confirm the service account has access to Firestore, Realtime Database, or Authentication, depending on which services you plan to query.
  • Malformed JSON: Ensure the full service account key was pasted without truncation or extra characters.
  • Database URL: If you're querying Realtime Database, confirm the Firebase database URL matches your Firebase project.

Save the resource

Click Create resource to save your Firebase resource. You can now use it in queries across your Retool apps and automations.

Interact with Firebase data

Once you've created a Firebase resource, you can interact with Firebase data using Retool.

Switch to the new app builder

Retool recommends using the new app builder so you can use natural language to build React-based apps using AI.

  • To use Firebase data in the app builder, reference the resource in the prompt with @, such as @Firebase (Production). Refer to the data and functions documentation to learn more.
  • For classic apps, workflows, and agents, refer to the resource query documentation to learn how to write a query.

Best practices

Follow these best practices to maintain the security of your Firebase resource.

  • Use a dedicated service account: Create a service account scoped to only the Firebase project and permissions the resource needs, rather than reusing a broadly-scoped account.
  • Rotate credentials regularly: Rotate the service account key on a regular schedule, and immediately if a key is ever exposed.
  • Restrict service account permissions: Assign the service account only the Google Cloud IAM roles and permissions the resource needs. Firebase Admin SDK requests use IAM authorization and bypass Firestore security rules.
  • Use resource environments: Organizations on an Enterprise plan can configure multiple resource environments to maintain separate Firebase credentials for production, staging, and development.