IntermediateFirebase Integration

What's the difference between Firestore and the Realtime Database?

Short Answer

Firestore is a newer, document/collection-based database with richer querying, automatic multi-region scaling, and better offline support; the Realtime Database is a simpler single JSON tree, cheaper for very high-frequency small writes but with weaker querying.

Firestore organizes data into documents (JSON-like objects) grouped into collections, and supports compound queries, indexing, and pagination natively. It scales horizontally across regions automatically and its offline persistence layer is more robust — queries work offline and sync seamlessly when reconnected.

The Realtime Database stores everything as one large JSON tree. It's historically been favored for use cases needing extremely low-latency, high-frequency updates (like live cursor positions or presence systems) because its WebSocket-based sync can be marginally faster for tiny, frequent writes, and its pricing model (bandwidth-based) can be cheaper at that specific workload shape. For most new apps, Google now recommends Firestore by default unless you have that specific high-frequency-small-write profile.

Common Mistakes

  • ×Assuming Realtime Database is deprecated — it isn't, it's just recommended for narrower use cases now.
  • ×Trying to run Firestore-style compound queries against the Realtime Database's flatter query model.