FireLogGet the app

Firestore vs Realtime Database: Which One Should You Use?

Firebase ships two databases with confusingly similar names. Here is what actually separates them, and how to choose.

9 min read · updated August 5, 2026

Firebase has two databases. Realtime Database came first, in 2012. Cloud Firestore arrived in 2017 and is the one Google now recommends for new projects.

Both sync data live to connected devices. Both work offline. The names do nothing to explain the difference, which is why this question gets asked constantly.

They store data in genuinely different shapes

Realtime Database is one enormous JSON object. Your entire database is a single tree. Everything hangs off one root.

{
  "users": {
    "user1": {
      "name": "Maya",
      "posts": {
        "post1": { "title": "Hello" }
      }
    }
  }
}

Firestore stores documents inside collections. A document is a bundle of fields. A collection is a folder of documents. Documents can hold their own sub-collections.

users (collection)
  └── user1 (document)
        ├── name: "Maya"
        └── posts (sub-collection)
              └── post1 (document)
                    └── title: "Hello"

This is not cosmetic. In Realtime Database, reading a node reads everything underneath it. Ask for a user and you also download every post they ever wrote. The usual workaround is flattening your data into separate top-level lists and stitching it together in the app.

In Firestore, reading a document gets you that document. Sub-collections are not included unless you ask. The structure you want is usually the structure you can have.

Querying is where the gap is widest

Realtime Database can sort or filter on one property at a time. That is the whole feature. Anything more and you are filtering in your app after downloading too much.

Firestore handles compound queries — several conditions at once, sorted, paginated.

import { collection, query, where, orderBy, limit, getDocs } from "firebase/firestore";

const q = query(
  collection(db, "orders"),
  where("status", "==", "shipped"),
  where("total", ">", 50),
  orderBy("total", "desc"),
  limit(20),
);

const snapshot = await getDocs(q);

There is a catch worth knowing early: compound queries need an index, and Firestore will not guess. The first time you run one it fails with an error containing a link. Click the link, the index is created, the query works. It feels like a bug the first time and is entirely normal.

How they charge you is the real decision

Realtime DatabaseFirestore
You pay forData downloaded, plus storageNumber of reads, writes and deletes, plus storage
A 500-document list costsThe bandwidth of 500 documents500 reads
Cheap whenDocuments are tiny and change constantlyYou read a few documents at a time
Expensive whenYou download large nodes repeatedlyYou list large collections on every screen

This trips people up. In Firestore, a query returning 500 documents costs 500 reads, even if each document is four bytes. Build a dashboard that lists everything on load, and a few hundred users can produce a surprising bill.

When Realtime Database is genuinely the better choice

It is older, not obsolete. Two cases where it still wins:

Using both in one project is allowed and reasonably common.

The rest of the differences, briefly

Realtime DatabaseFirestore
ScalingOne database, manual sharding past its limitsScales automatically
RegionsFewerMany, including multi-region
Offline supportMobile onlyMobile and web
TransactionsLimited to a single subtreeAcross collections
Security rulesCascade down the treePer collection and document, no cascading

That last row matters. In Realtime Database, granting read on a node grants it on everything below. In Firestore, rules apply exactly where you write them — which is safer, and requires you to be explicit.

So which one?

  1. New project, ordinary app? Firestore.
  2. Live cursors, game state, or presence? Realtime Database, possibly alongside Firestore.
  3. Already on Realtime Database and it works? Stay. Migrating is real work and "newer" is not a reason on its own.
  4. Unsure? Firestore. It is where the development effort goes.

Frequently asked questions

What is the difference between Firestore and Realtime Database?
Realtime Database stores everything as one large JSON tree and charges for data downloaded. Firestore stores documents in collections, supports compound queries, scales automatically, and charges per read and write operation.
Which is cheaper, Firestore or Realtime Database?
It depends on the shape of your traffic. Firestore charges per operation, so listing large collections is expensive. Realtime Database charges for bandwidth, so many tiny frequent updates are cheaper there.
Can I use both in the same project?
Yes, and it is a common pattern — Firestore for the main data, Realtime Database for presence detection, which it handles better.
Is Realtime Database deprecated?
No. It is still supported and still the better tool for high-frequency small updates. Google recommends Firestore for new projects, which is not the same as retiring the older one.
Why does my Firestore query need an index?
Queries filtering or sorting on more than one field need a composite index. The first run fails with an error containing a link that creates the index for you. This is expected behaviour, not a bug.
Does Firestore work offline?
Yes, on mobile and web. Reads come from a local cache and writes queue until the device reconnects. Realtime Database offline support is mobile only.

Keep reading