# Firebase Realtime Database

Store and sync data with our NoSQL cloud database. Data
is synced across all clients in realtime, and remains available when your
app goes offline.

### Realtime Database

[Video](https://www.youtube.com/watch?v=U5aeM5dvUpA)

### Cloud Firestore

Preferred [Video](https://www.youtube.com/watch?v=QcsAb2RR52c) The Firebase Realtime Database is a cloud-hosted database. Data is stored as JSON
and synchronized in realtime to every connected client. When you build
cross-platform apps with our Apple platforms, Android, and JavaScript SDKs, all of your
clients share one Realtime Database instance and automatically receive updates with
the newest data.

Alternatively, consider trying [Cloud Firestore](https://firebase.google.com/docs/firestore.md.txt) for modern
applications requiring richer data models, queryability, scalability and higher
availability.

<br />

Ready to get started? Choose your platform:

[iOS+](https://firebase.google.com/docs/database/ios/start.md.txt)
[Android](https://firebase.google.com/docs/database/android/start.md.txt)
[Web](https://firebase.google.com/docs/database/web/start.md.txt)
[Flutter](https://firebase.google.com/docs/database/flutter/start.md.txt)
[Unity](https://firebase.google.com/docs/database/unity/start.md.txt)
[C++](https://firebase.google.com/docs/database/cpp/start.md.txt)
[Admin](https://firebase.google.com/docs/database/admin/start.md.txt)
[REST API](https://firebase.google.com/docs/database/rest/start.md.txt)

## Key capabilities

|---|---|
| Realtime | Instead of typical HTTP requests, the Firebase Realtime Database uses data synchronization---every time data changes, any connected device receives that update within milliseconds. Provide collaborative and immersive experiences without thinking about networking code. |
| Offline | Firebase apps remain responsive even when offline because the Firebase Realtime Database SDK persists your data to disk. Once connectivity is reestablished, the client device receives any changes it missed, synchronizing it with the current server state. |
| Accessible from Client Devices | The Firebase Realtime Database can be accessed directly from a mobile device or web browser; there's no need for an application server. Security and data validation are available through the Firebase Realtime Database Security Rules, expression-based rules that are executed when data is read or written. |
| Scale across multiple databases | With Firebase Realtime Database on the Blaze pricing plan, you can support your app's data needs at scale by splitting your data across multiple database instances in the same Firebase project. Streamline authentication with Firebase Authentication on your project and authenticate users across your database instances. Control access to the data in each database with custom Firebase Realtime Database Security Rules for each database instance. |

## How does it work?

The Firebase Realtime Database lets you build rich, collaborative applications
by allowing secure access to the database directly from client-side code. Data
is persisted locally, and even while offline, realtime events continue to fire,
giving the end user a responsive experience. When the device regains connection,
the Realtime Database synchronizes the local data changes with the remote updates
that occurred while the client was offline, merging any conflicts automatically.

The Realtime Database provides a flexible, expression-based rules language,
called Firebase Realtime Database Security Rules, to define how your data should be
structured and when data can be read from or written to. When integrated with
Firebase Authentication, developers can define who has access to what data, and how
they can access it.

The Realtime Database is a NoSQL database and as such has different optimizations
and capabilities compared to a relational database. The Realtime Database API is
designed to only allow operations that can be executed quickly. This lets you
build a great realtime experience that can serve millions of users without
compromising on responsiveness. Because of this, it is important to think about
how users need to access your data and then
[structure it accordingly](https://firebase.google.com/docs/database/web/structure-data.md.txt).

## Implementation path

|---|---|---|
|   | Integrate the Firebase Realtime Database SDKs | Quickly include clients using Gradle, Swift Package Manager, or a script include. |
|   | Create Realtime Database References | Reference your JSON data, such as "users/user:1234/phone_number" to set data or subscribe to data changes. |
|   | Set Data and Listen for Changes | Use these references to write data or subscribe to changes. |
|   | Enable Offline Persistence | Allow data to be written to the device's local disk so it can be available while offline. |
|   | Secure your data | Use Firebase Realtime Database Security Rules to secure your data. |

## Store other types of data

- [Cloud Firestore](https://firebase.google.com/docs/firestore.md.txt) is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud. To learn more about the differences between database options, see [Choose a database: Cloud Firestore or Realtime Database](https://firebase.google.com/docs/firestore/rtdb-vs-firestore.md.txt).
- [Firebase Remote Config](https://firebase.google.com/docs/remote-config.md.txt) stores developer specified key-value pairs to change the behavior and appearance of your app without requiring users to download an update.
- [Firebase Hosting](https://firebase.google.com/docs/hosting.md.txt) hosts the HTML, CSS, and JavaScript for your website as well as other developer-provided assets like graphics, fonts, and icons.
- [Cloud Storage](https://firebase.google.com/docs/storage.md.txt) stores files such as images, videos, and audio as well as other user-generated content.

## Next steps:

- Set data and listen for changes using the [Apple platforms](https://firebase.google.com/docs/database/ios/start.md.txt), [Android](https://firebase.google.com/docs/database/android/start.md.txt), [Web](https://firebase.google.com/docs/database/web/start.md.txt), [Admin](https://firebase.google.com/docs/database/admin/start.md.txt) SDKs, or the [REST API](https://firebase.google.com/docs/database/rest/start.md.txt).
- Add Firebase Realtime Database to your [Apple](https://firebase.google.com/docs/database/ios/start.md.txt), [Android](https://firebase.google.com/docs/database/android/start.md.txt), or [Web](https://firebase.google.com/docs/database/web/start.md.txt) app.
- Learn about how to secure your files using [Firebase Realtime Database Security Rules](https://firebase.google.com/docs/database/security.md.txt).