透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Firebase Realtime Database
plat_ios
plat_android
plat_web
plat_flutter
plat_cpp
plat_unity
透過我們的 NoSQL 雲端資料庫儲存及同步處理資料。資料
系統會即時同步處理所有用戶端的資料,而且只要
應用程式離線。
Firebase Realtime Database 是雲端託管的資料庫。資料會以 JSON 格式儲存
並即時同步至每個連結的用戶端建構應用程式
導入我們的 Apple 平台、Android 和 JavaScript SDK,
用戶端會共用一個 Realtime Database 執行個體,並自動接收
最新資料
您也可以考慮改用 Cloud Firestore 執行現代化作業
需要更豐富的資料模型、可查詢性、擴充性以及更高版本的應用程式
提高可用性
準備好了嗎?選擇平台:
iOS 以上
Android
網站
Flutter
Unity
C++
管理員
REST API
主要功能
即時 |
Firebase Realtime Database 會使用資料,而非一般 HTTP 要求
同步處理:每次資料變更時,所有連線的裝置都會收到資料
都會在幾毫秒內更新提供協作與
沉浸式體驗,不必煩惱網路程式碼。
|
離線 |
即使離線,Firebase 應用程式仍能保持回應速度,因為
Firebase Realtime Database SDK 會將您的資料保存在磁碟中。連線後
已重新建立,用戶端裝置便會收到任何遺漏的變更
並將該檔案與目前的伺服器狀態同步處理。
|
可從用戶端裝置存取 |
您可以直接從行動裝置存取 Firebase Realtime Database
或網路瀏覽器;也不需要使用應用程式伺服器安全性與
資料驗證可透過 Firebase Realtime Database
安全性規則,以及資料發生時執行的運算式規則
讀取或寫入
|
擴充至多個資料庫 |
Blaze 定價方案中的 Firebase Realtime Database,即可享有支援
將資料分散至多個
資料庫執行個體。簡化驗證程序
使用 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 安全性規則保護資料。 |
儲存其他類型的資料
後續行動:
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-25 (世界標準時間)。
[null,null,["上次更新時間:2025-07-25 (世界標準時間)。"],[],[],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)."]]