# Connect a Firebase Realtime Database

## Overview

Firebase is a Google product that simplifies the development of mobile apps by providing out-of-the-box solutions for common mobile development needs, such as a simple realtime database and authentication. You can use a single Firebase project for both a realtime database and authentication.

Thunkable provides a default Firebase account for testing purposes, but before you distribute your app we strongly recommend connecting it to your personal Firebase account.

{% hint style="info" %}
Please note that while the images and instructions from the Firebase account are accurate at the time of this doc’s publishing, they may change slightly over time.
{% endhint %}

## Create a Firebase Account

1. Visit [Firebase](https://firebase.google.com/).
2. Click **Get Started** or **Sign in**.
3. Sign in with your existing Google account credentials or create an account.

## Create a Firebase Project

1. On your [Firebase console](https://console.firebase.google.com/u/0/), click **+ Add project**.
2. Give your project a name.
3. Click **Continue**.
4. Indicate whether or not you want to enable Google Analytics.
5. Click **Create project**.
6. When your new project is ready, click **Continue**.

## Create a Realtime Database

To create a Firebase Realtime Database:

1. Within your Firebase project, click to expand the **Build** menu in the left sidebar.
2. Select **Realtime Database**.
3. Click **Create Database**.
4. Select your **Realtime Database location**. This is where your data will be stored.
5. Click **Next**.
6. Select your preferred security rules.\
   **Start in locked mode** - Your data is private by default. Client read/write access will only be granted as specified by your security rules.\
   **Start in test mode** - Your data is open by default to enable quick setup. However, you must update your security rules within 30 days to enable long-term client read/write access.
7. Click **Enable**.
8. Build your database to your specifications.

### Sample Realtime Database

Below is a simple example of a Firebase Realtime Database.&#x20;

<div align="left"><figure><img src="https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LAn5scXl2uqUJUOqkJo-84897653%2Fuploads%2FATElVLEtlnaVldLkaumO%2Fsample%20Firebase%20Realtime%20Database.png?alt=media&#x26;token=88829ca8-c8c2-4590-94c8-c204212a4083" alt="" width="375"><figcaption></figcaption></figure></div>

## Connect Your Firebase Account to Thunkable

To connect your Firebase and Thunkable accounts, you need to locate two Firebase properties:

* API Key
* Database URL

These will need to be entered into Thunkable, so we recommend you have two browser tabs open, one for Firebase and one for Thunkable.

1. On your [Firebase console](https://console.firebase.google.com/u/0/), select your project.
2. Click the **gear icon** next to Project Overview.
3. Select **Project settings**.\
   ![](https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LAn5scXl2uqUJUOqkJo-84897653%2Fuploads%2FvBUkH6aB5ybgtjPriGbZ%2FFirebase%20Authentication%20-%20Project%20settings.png?alt=media\&token=4ae06971-0457-4752-a8ad-4e4ff618ade2)
4. In the Your apps section, locate the web app's SDK code snippet.

   <div align="left"><figure><img src="https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LAn5scXl2uqUJUOqkJo-84897653%2Fuploads%2FwPLFlSxz5SebpqcxfIco%2FFirebase%20Authentication%20-%20code%20snippet.png?alt=media&#x26;token=8c12de0b-27b2-4b97-a244-6a0c83084147" alt="" width="563"><figcaption></figcaption></figure></div>
5. Copy the **apiKey**.
6. In your Thunkable tab, click the **Settings gear icon** in the sidebar.
7. Scroll to the Firebase section and paste the apiKey into the Firebase **API Key** field.
8. Return to Firebase, and within the SDK code snippet, locate and copy the **databaseURL**.
9. Back in Thunkable, paste the databaseURL in the **Database URL** field.

## Video Tutorials

### How to Read Data in a Firebase Realtime Database

In this tutorial, you’ll learn how to read data from a connected Firebase Realtime Database.

{% embed url="<https://youtu.be/2TnfendzlBI>" %}

### How to Update Data in a Firebase Realtime Database

In this tutorial, you’ll learn how to update data in a connected Firebase Realtime Database.

{% embed url="<https://youtu.be/mY2omvP9oRM>" %}

## Related Docs

{% content-ref url="../../app-features/sign-in/sign-in" %}
[sign-in](https://docs.thunkable.com/blocks/app-features/sign-in/sign-in)
{% endcontent-ref %}

***

{% hint style="success" %}
**Have feedback on this doc?** Please take a moment to share your feedback here: [Thunkable Docs Feedback](https://docs.google.com/forms/d/e/1FAIpQLSfCwn5L2xyla-LSLZX0DSWFcFeJ43qp-r1tELCacuVS2zduLA/viewform?usp=sf_link). Your valuable insights will help us improve and better serve you in the future.
{% endhint %}
