← Back to blog

Published on

Which Firebase alternatives keep NoSQL and realtime?

Firestore and the Realtime Database are NoSQL databases, so the most natural Firebase alternative is often NoSQL as well. MongoDB Atlas is the closest match for the document model. Valkey, the open source Redis fork backed by the Linux Foundation, is the pick when you care about realtime and speed: it stores data as keys, hashes, sets, and sorted sets, pushes changes with Pub/Sub and Streams, and persists to disk with AOF. Supabase, Appwrite, and PocketBase round out the list if you want a ready-made backend. This guide shows how each Firebase building block maps to a Valkey command, what Valkey does not replace and how to fill each gap, and compares official prices in US dollars and Brazilian reais.

Which Firebase alternatives keep NoSQL and realtime?

The five most common picks are MongoDB Atlas, Valkey, Supabase, Appwrite, and PocketBase, and they solve different problems. MongoDB Atlas is the most direct swap for the data model, since it also stores JSON documents in collections. Valkey is an in-memory key-value database that sits behind your API and answers reads in under a millisecond, with Pub/Sub and Streams for realtime and disk persistence. Supabase and Appwrite are full backends with sign-in, file storage, and realtime, and PocketBase is an open source backend shipped as a single binary that you host yourself.

The right choice depends on how you use Firebase today. If your app relies on the SDK talking straight to the database, on security rules, and on the offline cache on the phone, a full backend such as Supabase or Appwrite changes the least. If what hurts is the per-read bill, latency, or the realtime layer of a chat, a leaderboard, or a live dashboard, Valkey behind your own API is usually faster and cheaper, as long as you are willing to write that API.

Prices in this guide were read on each product’s official pages on November 28, 2026. Conversions to Brazilian reais use the Central Bank of Brazil’s PTAX selling rate for November 27, 2026, R$5.5430 per US dollar, plus the 3.5% IOF tax that applies to international card purchases in Brazil, which works out to R$5.7370 per dollar. Zenifra prices come from its public plan catalog, checked the same day.

Why are Firestore and the Realtime Database NoSQL?

Because neither has tables or a fixed schema. Firestore stores documents, which are sets of fields and values grouped into collections, and documents in the same collection can have different fields. The Realtime Database is even simpler: its documentation says data is stored as JSON and synchronized in realtime to every connected client, in a single tree where each path works as a key.

What made Firebase popular was not the format, it was realtime. In Firestore, onSnapshot delivers the document’s current contents on the first call and fires again on every change. Local writes trigger the listener immediately, before they reach the server, and the mobile SDK keeps data on disk so the app works without a network. Security rules decide on Google’s side who can read and write each path, which is why the app can talk to the database directly.

The bill follows that model. On Firestore Standard, the free quota is 50,000 reads, 20,000 writes, and 20,000 deletes per day, with 1 GiB stored. Above it, in São Paulo (southamerica-east1), every 100,000 reads cost US$0.045 and every 100,000 writes US$0.135. The pricing page also explains that a listener is charged one read for each document added to or changed in its results, and that with offline persistence enabled, a listener disconnected for more than 30 minutes is billed as a brand-new query when it comes back. On the Realtime Database, the Blaze plan charges US$5 per GB stored above 1 GB and US$1 per GB downloaded above 360 MB a day, with a limit of 200,000 simultaneous connections per database.

Monthly usageFirebase in US dollarsIn reais, with PTAX and 3.5% IOF
Firestore in São Paulo, 100,000 reads per dayUS$0.675R$3.87
Firestore in São Paulo, 1 million reads per dayUS$12.825R$73.58
Firestore in São Paulo, 10 million reads per dayUS$134.325R$770.62
Realtime Database, 100 GB downloadedUS$89.20R$511.74

The table covers reads and downloads only, over 30 days, after the free quota. For a small app, Firebase is cheap. Growth is what changes the math: every screen view and every active listener turns into billed reads, and a chat or a live dashboard multiplies that number fast.

Can Valkey work as a NoSQL alternative to Firebase?

Yes, once you understand where it fits. Valkey started on March 28, 2024, when the Linux Foundation announced it would continue development of Redis 7.2.4 under the 3-clause BSD license, after Redis Inc. changed the original project’s license. Redis clients and commands work with it, and the official site describes it as a high-performance key-value datastore that can serve as a primary database. As of November 2026, the current line is 9.x.

Unlike Firestore, Valkey does not talk to your app. It sits behind your API, keeps everything in memory, and answers simple commands, each one working on a data structure. That is the trade-off that matters: you give up querying by any field and get very fast reads with no per-document charge. The table shows how each Firebase concept is usually modeled.

In FirebaseIn ValkeyCommands
Document with fieldsHash at key order:{id}HSET, HGETALL, HINCRBY
Collection ordered by dateSorted set with the timestamp as scoreZADD, ZRANGE ... REV LIMIT
Query on one field (where)Set maintained by your app, such as orders:status:paidSADD, SMEMBERS, SINTER
Counter or likesNumeric stringINCR, INCRBY
Firestore TTLExpiration on a key or on a single hash fieldEXPIRE, HSETEX (since Valkey 9.0)
Realtime listenerPub/Sub or a Stream read by your APIPUBLISH, SUBSCRIBE, XADD, XREAD
Batched transactionAtomic blockMULTI and EXEC, or a Lua script

Your data does not live only in memory. With AOF enabled, Valkey appends every write to a file on disk and replays it after a restart. The persistence docs explain that with appendfsync everysec, you can lose about 1 second of writes in a disaster. On Zenifra’s Key-Value Valkey, for example, AOF runs with appendfsync everysec, and plans from DB-Basic up have one primary and two replicas, with the primary accepting writes only while at least one replica is connected.

What does a Firestore document look like in Valkey?

Take an orders app. In Firestore, each order is a document in orders, and the "My orders" screen runs a query with where("userId", "==", uid), orderBy("createdAt", "desc"), and limit(20). In Valkey, the order becomes a hash, and the query becomes a per-user sorted set that your app updates in the same atomic block as the write.

The example below uses the iovalkey client in Node.js, with the TLS connection Zenifra’s docs recommend. The write does three things at once inside a MULTI: it saves the order fields, adds the id to the user’s index, and appends an event to the user’s stream, which is what replaces the listener in the next section.

javascript
import Redis from "iovalkey"

const url = new URL(process.env.VALKEY_URL)
export const valkey = new Redis({
  host: url.hostname,
  port: Number(url.port),
  username: decodeURIComponent(url.username),
  password: decodeURIComponent(url.password),
  tls: { servername: url.hostname },
})

// Firestore: setDoc(doc(db, "orders", order.id), { ...order, createdAt })
export async function saveOrder(order) {
  const createdAt = Date.now()
  await valkey
    .multi()
    .hset(`order:${order.id}`, { userId: order.userId, status: order.status, totalCents: String(order.totalCents), createdAt: String(createdAt) })
    .zadd(`user:${order.userId}:orders`, createdAt, order.id)
    .xadd(`user:${order.userId}:events`, "MAXLEN", "~", "1000", "*", "type", "order", "id", order.id, "status", order.status)
    .exec()
}

// Firestore: query(collection(db, "orders"), where("userId", "==", uid), orderBy("createdAt", "desc"), limit(20))
export async function latestOrders(userId) {
  const ids = await valkey.zrange(`user:${userId}:orders`, 0, 19, "REV")
  const pipeline = valkey.pipeline()
  for (const id of ids) pipeline.hgetall(`order:${id}`)
  const results = await pipeline.exec()
  return results.map(([, data], i) => ({ id: ids[i], ...data }))
}
bash
# The same model, straight from valkey-cli
HSET order:A1 userId u42 status paid totalCents 12990
ZADD user:u42:orders 1764331200000 A1
SADD orders:status:paid A1

# A session that expires in 1 hour and presence that disappears after 30 seconds
SET session:abc123 u42 EX 3600
HSETEX presence:room:7 EX 30 FIELDS 1 u42 online

Notice that the index is your job. If the screen later needs to filter by status and date at the same time, you add another sorted set or combine the existing ones, because Valkey does not search inside hashes. That is the main difference in day-to-day work compared to Firestore, and it is why Valkey shines on screens with a few well-known access patterns.

What replaces Firebase realtime listeners?

An open connection between your app and your API, over WebSocket or Server-Sent Events (SSE), fed by Valkey. Valkey offers two mechanisms, and the difference between them decides what happens when a phone drops off the network for a few seconds.

Pub/Sub is the simpler one: your API runs PUBLISH on a channel, and every process subscribed with SUBSCRIBE gets the message. Valkey’s documentation describes delivery as at-most-once, so anyone disconnected at that moment misses the event. It works well for typing indicators, online presence, and cache invalidation. Streams keep the events: XADD appends an entry with an id, and XREAD BLOCK waits for new entries after a given id. If a client reconnects with the last id it received, it gets what it missed, as long as the event is still within the MAXLEN limit.

The example below swaps onSnapshot for an SSE route. The browser resends the Last-Event-ID header on its own when EventSource reconnects, so the route picks up where it left off. With several API instances, each connection lives on one instance and all of them read the same stream, which handles fan-out to every client without extra coordination.

javascript
// Before, in the app: the Firestore SDK fires on every change
onSnapshot(query(collection(db, "orders"), where("userId", "==", uid)), snap => render(snap.docs))

// After, in the API (Express): an SSE route reads the user stream with XREAD BLOCK
app.get("/events", async (req, res) => {
  const uid = await authenticate(req) // Firebase Auth verifyIdToken() or your own session
  res.set({ "Content-Type": "text/event-stream", "Cache-Control": "no-cache" })
  res.flushHeaders()
  const reader = valkey.duplicate()
  let lastId = req.get("Last-Event-ID") || "$"
  let open = true
  req.on("close", () => { open = false; reader.disconnect() })
  while (open) {
    const reply = await reader.xread("BLOCK", 25000, "STREAMS", `user:${uid}:events`, lastId).catch(() => null)
    for (const [, entries] of reply ?? []) {
      for (const [id, fields] of entries) {
        lastId = id
        res.write(`id: ${id}\ndata: ${JSON.stringify(fields)}\n\n`)
      }
    }
  }
})

// In the app: EventSource reconnects on its own and sends Last-Event-ID
const events = new EventSource("/events", { withCredentials: true })
events.onmessage = e => applyChange(JSON.parse(e.data))

Each XREAD BLOCK holds a Valkey connection, which is why the example calls duplicate() per client. With thousands of connected users, switch to a single reader per instance that fans events out in memory, or to SUBSCRIBE on per-room channels. On Zenifra, WebSocket and SSE work on the project’s regular HTTP port, custom domains included, and the docs recommend exactly this kind of shared channel when the API runs several instances.

What doesn’t Valkey replace in Firebase?

Sign-in is the first gap. Valkey stores sessions very well, with SET session:{id} ... EX 3600, but it does not register users, send confirmation emails, or handle social login. The shortest path is to keep Firebase Authentication, which stays free up to 50,000 monthly active users, and verify the ID token in your API with the Admin SDK’s verifyIdToken(). If you want to leave Google entirely, use an authentication library on the backend, such as Better Auth or Auth.js, and keep users in a relational database.

The offline cache in the mobile SDKs has no ready-made equivalent either. Firestore writes on the device, shows the change right away, and syncs when the network returns. With your own API, the app needs local storage, such as SQLite on the phone or IndexedDB in the browser, a queue of pending writes, and client-generated ids so retries never create duplicates. Replaying from Last-Event-ID covers short connection drops, not days offline. If your app was built to work offline for long stretches, budget for that work before migrating.

Security rules move somewhere else. Valkey has users and ACLs to protect the server, but it does not decide whether user 42 may read user 7’s order. That check moves into your API, which reads the uid from the token and only builds keys that belong to that user. The Valkey password never ships inside the app, even if the service has public access turned on.

Finally, rich queries. Without secondary indexes, filtering on any field, full-text search, or a monthly report requires structures built ahead of time or a different database. Your dataset also has to fit in the plan’s memory: on Zenifra’s Valkey, 80% of RAM goes to data, which is 204 MB on DB-Starter and 819 MB on DB-Basic, and once memory is full, writes return an error instead of evicting keys. Put TTLs on whatever expires and keep an eye on memory usage.

Firebase vs MongoDB Atlas, Supabase, Appwrite, and PocketBase: how do they compare?

The table lists the alternatives people search for most when leaving Firebase, with Valkey on Zenifra as a reference for a managed NoSQL database behind your own API. Prices are the entry prices published on November 28, 2026, and the BRL figures add the November 27, 2026 PTAX rate and the 3.5% IOF.

OptionData modelRealtimeSign-in includedRegion in BrazilEntry paid priceIn reais
FirebaseDocuments (Firestore) and a JSON tree (Realtime Database)SDK listeners with offline cacheYes, free up to 50,000 monthly active usersYes, southamerica-east1Usage-based: US$0.045 per 100,000 reads in São PauloVaries with usage, plus IOF
MongoDB AtlasBSON documents in collectionsChange streams, read by your backendNoLists São Paulo (sa-east-1) among its AWS regionsFlex from US$8/month, capped at US$30; M10 from US$56.94/monthR$45.90 to R$172.11 on Flex; R$326.67 on M10
SupabasePostgreSQL with JSONB columnsRealtime: 500 connections and 5 million messages on ProYes, 100,000 monthly active users on ProYes, sa-east-1Pro from US$25/monthR$143.43
Appwrite CloudTablesDB by default; DocumentsDB, PostgreSQL, and MySQL as optionsRealtime APIYesNo: Frankfurt, New York, Sydney, San Francisco, Singapore, and TorontoPro US$25/month; dedicated database from US$10/monthR$143.43 on Pro
PocketBaseEmbedded SQLite in a single binaryRealtime subscriptionsYesWherever you host itFree, self-hosted onlyYour server’s price
Valkey on ZenifraKeys, hashes, sets, sorted sets, and Streams, with AOFPub/Sub and Streams through your APINo; Firebase Auth or a library in your APIYes, São PauloDB-Starter R$11.90/month plus diskR$11.90, no IOF

Free tiers are left out of the table, but they exist. Atlas has M0, with 512 MB and no backups. Supabase Free allows 2 active projects with a 500 MB database and pauses a project after 1 week of inactivity. Appwrite Free allows 2 projects and freezes a project when it hits a limit. On Zenifra, the way to try things out is hourly billing: the Valkey DB-Starter costs R$0.018 per hour, plus disk.

Firebase vs MongoDB: which one is closer?

On the data model, MongoDB. A Firestore document becomes a MongoDB document with almost no transformation, and field queries, with secondary indexes and aggregations, go further than Firestore’s. If you have many collections and screens that filter on several fields, it is the migration with the least remodeling.

The difference is everything around the database. MongoDB deprecated Atlas Device Sync and the Atlas Device SDKs, which handled offline sync on mobile, with end of life on September 30, 2025, and App Services authentication went with them. Today Atlas is a managed database: your app talks to your API, and realtime comes from change streams read by the backend. In practice, the work on the API, sign-in, and realtime is the same as with Valkey, with a document database in place of a key-value store.

When is another alternative a better fit than Valkey?

When your app depends on the SDK talking directly to the database and you do not want to write an API. In that case, Supabase or Appwrite change your architecture less, because they ship sign-in, access rules, files, and realtime out of the box. Supabase has a São Paulo region with Postgres underneath; Appwrite added DocumentsDB in September 2026, a schemaless document database, but it has no South American region and only accepts cards.

When your data is too large for memory or needs ad hoc queries, an on-disk document database such as MongoDB makes more sense than an in-memory key-value store. When the app is small, fits on one server, and you are fine reading the changelog on every upgrade, PocketBase does the job with a single binary, keeping in mind that its own docs do not recommend it for critical production apps before version 1.0. And when the mobile offline cache is the heart of your product, staying on Firebase may be the right call.

Valkey wins when access patterns are known and realtime is the core: chat, notifications, leaderboards, carts, sessions, rate limits, and live dashboards. On those screens, in-memory key lookups and an event stream replace listeners with no per-document read charge.

How do you migrate data from Firestore to Valkey?

With a script that reads your collections through the Admin SDK and writes each document as a hash, building the indexes your screens will need along the way. Before writing the script, list the queries your app runs today, because they define the keys: every where with orderBy becomes a sorted set, and every equality filter becomes a set. A document that no query touches needs no index at all.

Valkey hashes hold only flat strings and numbers. So the script converts each Timestamp to milliseconds, which also work as sorted set scores, turns references into plain ids, and decides where each nested field goes. Small maps can become a single field holding JSON; arrays that grow, such as order items or group members, are better off in their own key, as a set or another hash. Read in pages with orderBy and startAfter and write in a pipeline, so you avoid one round trip per document.

The script’s reads are billed as regular Firestore reads: in São Paulo, 1 million documents cost US$0.45 above the daily free quota, or R$2.58 with PTAX and the 3.5% IOF. Run the full load once as a rehearsal, compare each collection’s document count with the size of its sorted sets, and check memory with INFO memory to confirm the data fits in your plan with room to spare.

For the cutover, the safest path is a dual-write period. Your API writes to both Firestore and Valkey, the full load runs again to catch whatever changed, and reads move over one screen at a time. Once the last screen reads from Valkey, the app stops writing to Firestore, and the old project stays up for a few days in read-only use, in case you need to roll back.

javascript
import { initializeApp, applicationDefault } from "firebase-admin/app"
import { getFirestore, Timestamp } from "firebase-admin/firestore"
import { valkey } from "./valkey.js"

initializeApp({ credential: applicationDefault() })
const db = getFirestore()

let last = null
for (;;) {
  let page = db.collection("orders").orderBy("createdAt").limit(500)
  if (last) page = page.startAfter(last)
  const snap = await page.get()
  if (snap.empty) break
  const pipeline = valkey.pipeline()
  for (const doc of snap.docs) {
    const o = doc.data()
    const createdAt = o.createdAt instanceof Timestamp ? o.createdAt.toMillis() : Number(o.createdAt)
    pipeline.hset(`order:${doc.id}`, { userId: o.userId, status: o.status, totalCents: String(o.totalCents), createdAt: String(createdAt), items: JSON.stringify(o.items ?? []) })
    pipeline.zadd(`user:${o.userId}:orders`, createdAt, doc.id)
    pipeline.sadd(`orders:status:${o.status}`, doc.id)
  }
  await pipeline.exec()
  last = snap.docs[snap.docs.length - 1]
}
await valkey.quit()

The field names (userId, status, totalCents, items) come from the example; swap in your own. If your app also uses Cloud Storage, the files move to S3-compatible object storage, and Valkey keeps only each file’s path.

When should you pair Valkey with PostgreSQL?

When part of your data needs reporting, ad hoc filters, or integrity across tables. A common setup keeps hot, constantly changing data in Valkey, such as sessions, presence, counters, and the event stream, and keeps customers, orders, and history in PostgreSQL, where reports run with GROUP BY and JOIN. The API writes to PostgreSQL, publishes the event to Valkey, and serves live screens from it.

If your Firebase pain is more about queries and reports than realtime, start with PostgreSQL. The Firebase to PostgreSQL migration guide walks through the Firestore export, the schema, and the data load, and the post on managed Redis and Valkey in Brazil compares Valkey providers in detail.

How much does a managed Valkey cost in reais?

On Zenifra, Valkey comes in three profiles, chosen at creation. Key-Value writes to disk with AOF and is included in automatic backups; Cache lives only in memory, with no backups, and evicts the least used keys when full; Queues also use AOF, include 5 GB of disk, and are meant for Pub/Sub and Streams. All of them speak the Redis protocol, with TLS on every connection.

One detail when reading the catalog: prices are per instance. On high-availability plans, which run one primary and two replicas, you pay 3 times the plan price, and extra disk is also counted on all 3 copies.

Profile and planResourcesMonthly price
Key-Value DB-Starter0.3 vCPU, 256 MB, 1 instance, backup every 24 h kept for 7 daysR$11.90 plus disk
Key-Value DB-Basic1 vCPU, 1 GB, one primary and two replicas, backup every 12 h kept for 7 daysR$49.90 per instance, R$149.70 for all 3, plus disk
Cache Starter0.5 vCPU, 512 MiB, memory onlyR$34.90
Queue Starter0.5 vCPU, 512 MiB, 5 GB with AOF includedR$44.90

For the orders app in this guide, an API on the Basic plan (R$29.90) with the Valkey DB-Starter (R$11.90) comes to R$41.80 per month plus the Valkey disk, which starts at 1 GB. The calculator shows the exact figure for your setup, and you pay by PIX, boleto, or card, in reais.

Summary

Firebase is NoSQL, and your replacement can stay NoSQL too. MongoDB Atlas is the closest on the document model, Supabase and Appwrite are the closest on the ready-made backend experience, and PocketBase is the simplest to self-host. Valkey is the pick when realtime and speed matter more than ad hoc queries: hashes instead of documents, sorted sets instead of ordered queries, and Streams instead of listeners, with your own API handling sign-in, permissions, and offline behavior.

If your users are in Brazil, it is worth running that Valkey in São Paulo and paying in reais; on Zenifra, it starts at R$11.90 per month.

See Valkey and managed database plans

We respect your privacy

We use essential cookies to run this site. Measurement and marketing cookies, such as Google Ads, are only enabled when you accept all cookies. Read our cookie policy.