コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Firebase Realtime Database
plat_ios
plat_android
plat_web
plat_flutter
plat_cpp
plat_unity
NoSQL クラウド データベースでデータの保管と同期を行うことができます。データはすべてのクライアントにわたってリアルタイムで同期され、アプリがオフラインになっても引き続き使用できます。
Firebase Realtime Database はクラウドでホストされるデータベースです。データは JSON として保存され、接続されているすべてのクライアントとリアルタイムに同期されます。Apple プラットフォーム、Android、JavaScript SDK を使用してクロスプラットフォーム アプリを構築した場合、すべてのクライアントが、1 つの Realtime Database インスタンスを共有して、最新のデータによる更新を自動的に受信します。
より豊富なデータモデル、クエリ可能性、スケーラビリティ、高可用性を必要とする最新のアプリケーションには、Cloud Firestore を試すことを検討してください。
準備ができたらプラットフォームを選択します。
iOS+
Android
ウェブ
Flutter
Unity
C++
Admin
REST API
主な機能
リアルタイム |
Firebase Realtime Database は、一般的な HTTP リクエストではなくデータ同期を使用します。データが変更されるたびに、接続されているあらゆるデバイスがその更新を数ミリ秒以内に受信します。ネットワーク処理を行うコードについて考えることなく、没入感の高いコラボレーション体験を実現できます。 |
オフライン |
Firebase アプリはオフラインでも応答できる状態を保ちます。これは、Firebase Realtime Database SDK がデータをディスクに永続化するためです。接続が再確立されると、クライアント デバイスは不足している変更内容を受信して、現在のサーバーの状態と同期します。 |
クライアント デバイスからアクセス可能 |
Firebase Realtime Database にはモバイル デバイスやウェブブラウザから直接アクセスできます。アプリケーション サーバーは必要ありません。セキュリティとデータの検証は Firebase Realtime Database セキュリティ ルールによって実現します。このルールは、データの読み取り時または書き込み時に実行される式ベースのルールです。 |
複数のデータベースにわたるスケーリング |
Firebase Realtime Database を Blaze お支払いプランで使用すると、同じ Firebase プロジェクト内の複数のデータベース インスタンスにデータを分割することで、アプリケーションのデータニーズを大規模にサポートできます。プロジェクトで Firebase Authentication を使用すると認証を効率化し、データベース インスタンス全体でユーザーを認証できます。それぞれのデータベース インスタンスにカスタム Firebase Realtime Database Security Rules を使用して、各データベースのデータに対するアクセスを制御できます。 |
仕組み
Firebase Realtime Database では、クライアント側のコードから直接、データベースへのセキュアなアクセスを可能にすることで、多機能なコラボレーション アプリケーションを構築できます。データはローカルで永続化され、オフラインでも、リアルタイム イベントは引き続き発生します。これにより、エンドユーザーに応答性の高い体験が提供されます。デバイスがオンラインになると、デバイスのオフライン中にリモートで発生した変更とローカルの変更を Realtime Database が自動的に同期し、競合があれば自動的に解決します。
Realtime Database には、Firebase Realtime Database セキュリティ ルールという柔軟性に優れた式ベースのルール言語が用意されています。この言語で、データの構造と、データの読み取りや書き込みが可能になるタイミングを定義します。Firebase Authentication と統合すると、アクセスを許可する対象のユーザーとデータ、ユーザーによるアクセスの方法をデベロッパーが定義できます。
Realtime Database は NoSQL データベースであり、リレーショナル データベースとは機能や最適化の方法が異なります。Realtime Database API は、短時間で実行できるオペレーションのみが可能なように設計されています。この設計によって、応答性を低下させることなく、数百万ものユーザーにサービスを提供できる優れたリアルタイムの操作性を実現できます。このため、ユーザーがどのような方法でデータにアクセスする必要があるのかという点を踏まえて、データを構造化することが重要です。
実装パス
|
Firebase Realtime Database SDK を統合する |
Gradle、CocoaPods、またはスクリプト インクルードを使用してクライアントをすばやく統合します。 |
|
Realtime Database 参照を作成する |
JSON データ("users/user:1234/phone_number" など)を参照してデータの設定やデータ変更のサブスクライブを行います。
|
|
データを設定し、変更をリッスンする |
これらの参照を使用してデータの書き込みや変更のサブスクライブを行います。 |
|
オフラインの永続性を有効にする |
デバイスのローカル ディスクへのデータの書き込みを許可して、オフラインでもデータを利用できるようにします。 |
|
データをセキュリティで保護する |
Firebase Realtime Database セキュリティ ルールを使用してデータを保護します。 |
その他のタイプのデータを保存する
次のステップ:
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-08-04 UTC。
[null,null,["最終更新日 2025-08-04 UTC。"],[],[],null,["Firebase Realtime Database \nplat_ios plat_android plat_web plat_flutter plat_cpp plat_unity \nStore and sync data with our NoSQL cloud database. Data\nis synced across all clients in realtime, and remains available when your\napp goes offline. \n\nRealtime Database \n\nCloud Firestore Preferred \nThe Firebase Realtime Database is a cloud-hosted database. Data is stored as JSON\nand synchronized in realtime to every connected client. When you build\ncross-platform apps with our Apple platforms, Android, and JavaScript SDKs, all of your\nclients share one Realtime Database instance and automatically receive updates with\nthe newest data.\n\nAlternatively, consider trying [Cloud Firestore](/docs/firestore) for modern\napplications requiring richer data models, queryability, scalability and higher\navailability.\n\n\u003cbr /\u003e\n\nReady to get started? Choose your platform:\n\n[iOS+](/docs/database/ios/start)\n[Android](/docs/database/android/start)\n[Web](/docs/database/web/start)\n[Flutter](/docs/database/flutter/start)\n[Unity](/docs/database/unity/start)\n[C++](/docs/database/cpp/start)\n[Admin](/docs/database/admin/start)\n[REST API](/docs/database/rest/start) \n\nKey capabilities\n\n|---------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| 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. |\n| 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. |\n| 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. |\n| 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. |\n\nHow does it work?\n\nThe Firebase Realtime Database lets you build rich, collaborative applications\nby allowing secure access to the database directly from client-side code. Data\nis persisted locally, and even while offline, realtime events continue to fire,\ngiving the end user a responsive experience. When the device regains connection,\nthe Realtime Database synchronizes the local data changes with the remote updates\nthat occurred while the client was offline, merging any conflicts automatically.\n\nThe Realtime Database provides a flexible, expression-based rules language,\ncalled Firebase Realtime Database Security Rules, to define how your data should be\nstructured and when data can be read from or written to. When integrated with\nFirebase Authentication, developers can define who has access to what data, and how\nthey can access it.\n\nThe Realtime Database is a NoSQL database and as such has different optimizations\nand capabilities compared to a relational database. The Realtime Database API is\ndesigned to only allow operations that can be executed quickly. This lets you\nbuild a great realtime experience that can serve millions of users without\ncompromising on responsiveness. Because of this, it is important to think about\nhow users need to access your data and then\n[structure it accordingly](/docs/database/web/structure-data).\n\nImplementation path\n\n|---|-----------------------------------------------|------------------------------------------------------------------------------------------------------------|\n| | Integrate the Firebase Realtime Database SDKs | Quickly include clients using Gradle, CocoaPods, or a script include. |\n| | Create Realtime Database References | Reference your JSON data, such as \"users/user:1234/phone_number\" to set data or subscribe to data changes. |\n| | Set Data and Listen for Changes | Use these references to write data or subscribe to changes. |\n| | Enable Offline Persistence | Allow data to be written to the device's local disk so it can be available while offline. |\n| | Secure your data | Use Firebase Realtime Database Security Rules to secure your data. |\n\nStore other types of data\n\n- [Cloud Firestore](/docs/firestore) 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](/docs/firestore/rtdb-vs-firestore).\n- [Firebase Remote Config](/docs/remote-config) stores developer specified key-value pairs to change the behavior and appearance of your app without requiring users to download an update.\n- [Firebase Hosting](/docs/hosting) hosts the HTML, CSS, and JavaScript for your website as well as other developer-provided assets like graphics, fonts, and icons.\n- [Cloud Storage](/docs/storage) stores files such as images, videos, and audio as well as other user-generated content.\n\nNext steps:\n\n- Set data and listen for changes using the [Apple platforms](/docs/database/ios/start), [Android](/docs/database/android/start), [Web](/docs/database/web/start), [Admin](/docs/database/admin/start) SDKs, or the [REST API](/docs/database/rest/start).\n- Add Firebase Realtime Database to your [Apple](/docs/database/ios/start), [Android](/docs/database/android/start), or [Web](/docs/database/web/start) app.\n- Learn about how to secure your files using [Firebase Realtime Database Security Rules](/docs/database/security)."]]