Firebase Realtime Database is Google's cloud-hosted NoSQL database that stores data as JSON and synchronizes it in real-time across all connected clients—typically within milliseconds. Unlike traditional databases requiring HTTP polling, it uses WebSocket-based data synchronization where every write instantly pushes updates to all listening devices, making it ideal for collaborative apps, chat systems, and live dashboards. Data persists locally during offline periods and automatically syncs when connectivity returns, merging conflicts server-side. A key design principle: flatten your data structure aggressively—because fetching a node retrieves all child data, deeply nested trees force massive downloads and break granular security rules, so denormalization (duplicating data across paths) is the norm, not the exception.
What This Cheat Sheet Covers
This topic spans 19 focused tables and 142 indexed concepts, 95 flashcards. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
Table 1: SDK Initialization & Setup
Every Firebase app starts here—wiring up the SDK, pointing it at your database, and grabbing references to the JSON paths you'll read and write. The databaseURL format varies by region, and connecting to the local emulator is a one-liner you slot in right after getDatabase().
| Method | Example | Description | |
|---|---|---|---|
import { initializeApp } from "firebase/app"const app = initializeApp({ databaseURL: "https://NAME.firebaseio.com" }) | • Initializes the Firebase app with your project config • databaseURL is required for RTDB. | ||
import { getDatabase } from "firebase/database"const db = getDatabase(app) | • Returns the database service instance • pass app explicitly when using multiple Firebase apps. | ||
import { ref } from "firebase/database"const usersRef = ref(db, 'users/123') | • Creates a database reference to a specific path • root reference: ref(db) with no path. | ||
const nameRef = child(usersRef, 'profile/name') | Returns a child reference relative to an existing reference without triggering any read. | ||
https://NAME.firebaseio.com (us-central1)https://NAME.REGION.firebasedatabase.app (other regions) | • The URL format depends on the database region • all other regions use the regional suffix. | ||
connectDatabaseEmulator(db, "127.0.0.1", 9000) | • Redirects all SDK calls to the local RTDB emulator • call this immediately after getDatabase(), before any reads or writes. |