Skip to content
Tutorials Center
My learning

Topics

Lesson 2 of 31 ยท Backend as a Service

Firebase vs Supabase: Choosing

Compare Firebase and Supabase side by side: NoSQL vs Postgres, open source vs proprietary, features, costs and migration, with a scoring checklist.

Firebase and Supabase solve the same problem, yet they feel very different. Firebase grew out of a realtime document database and is part of Google's cloud. Supabase wraps a regular PostgreSQL database with auth, storage, realtime and functions, and publishes its code as open source. Choosing between them is mostly a question of how your data looks and how much control you want.

This lesson gives you a map of both, then a method for deciding. It builds on What Is a Backend as a Service?. The real SDK snippets below are read-only; the scoring tool at the end is a runnable stand-in of ours.

The core difference: documents or tables

Firebase's main database is Cloud Firestore, a NoSQL store of documents grouped in collections. A document is a JSON-like object. There are no joins, so you copy data to where it will be read. Supabase gives you PostgreSQL: tables, columns, foreign keys and full SQL with joins, aggregates and transactions.

Here is the same read of "the 10 newest published posts" in each SDK. Both are read-only code.

JavaScript
// Firebase (modular SDK, Firestore)
import { collection, query, where, orderBy, limit, getDocs } from "firebase/firestore";

const q = query(
  collection(db, "posts"),
  where("published", "==", true),
  orderBy("createdAt", "desc"),
  limit(10)
);
const snapshot = await getDocs(q);
const posts = snapshot.docs.map((doc) => ({ id: doc.id, ...doc.data() }));
JavaScript
// Supabase (supabase-js, PostgreSQL)
const { data: posts, error } = await supabase
  .from("posts")
  .select("id, title, author:profiles(name)")   // a join through a foreign key
  .eq("published", true)
  .order("created_at", { ascending: false })
  .limit(10);

Notice the join in the second example: author:profiles(name) pulls the author's name from another table in one request. In Firestore you would store the author's name inside each post document, or run a second read.

Two shapes of data

Firestore Documents in collections. Copy data to read fast.
Postgres Tables with relations. Join when you read.

Pick the shape that matches how your app reads data.

1 / 2

Feature map side by side

Need Firebase Supabase
Database Firestore (documents), Realtime Database (JSON tree) PostgreSQL (tables, SQL)
Authentication Firebase Authentication Supabase Auth (GoTrue)
Data protection Security Rules Row level security policies
Realtime Snapshot listeners Realtime channels (changes, broadcast, presence)
Files Cloud Storage for Firebase Supabase Storage
Server code Cloud Functions (Node, Python) Edge Functions (Deno), database functions
Hosting Firebase Hosting Bring your own (or a partner host)
Local testing Emulator Suite Local stack in Docker via the CLI
Mobile Strong first-party SDKs for iOS, Android, Flutter Client libraries for many languages, strongest on JavaScript
Offline Built-in local cache and offline queue Not built in; you add your own caching

Both products grow constantly, so treat this table as a guide to the shape of each platform, and check the current docs for specifics.

Open source and self-hosting

Supabase's components (Postgres, the auth server, the realtime server, the storage API) are open source, so you can run the whole stack on your own machines. Self-hosting means you take over updates, backups and scaling, so most teams use the hosted service and keep self-hosting as an exit door. Firebase is a closed Google product: there is no way to run it yourself. The Emulator Suite is for local development and testing only.

When each one wins

Firebase tends to win when

  • You build a mobile app and want strong offline support and first-party SDKs.
  • Your data is naturally hierarchical and read in simple shapes (a feed, a chat, a profile).
  • You want realtime sync with very little setup.
  • You already use other Google Cloud services.

Supabase tends to win when

  • Your data is relational: orders with items, users with teams, anything with many-to-many links.
  • You need reports, aggregates and ad hoc queries across all rows.
  • You value standard SQL and being able to leave with a plain database dump.
  • You want to self-host or avoid being tied to one cloud vendor.

If both would work, the deciding question is often: will I need to ask questions about my data that I did not plan for? SQL answers new questions easily. A document store answers the questions you designed for, quickly, and the rest with effort. See Modeling Data: Documents vs Tables for the details.

Migration costs

Moving later is possible, but not free.

  • Firebase to Supabase. You must redesign the data: documents become tables with keys, copied fields turn into joins, and subcollections become related tables. Auth users can be exported with their password hashes, and you must rewrite every rule as a policy and every SDK call.
  • Supabase to Firebase. Rare. Relational data must be denormalized, and joins and aggregates in your app have to be redone.
  • Supabase to anywhere Postgres runs. The easiest: dump the database, restore it elsewhere, and replace the Supabase-specific layers (auth, storage, realtime) step by step.

The cheapest insurance is the adapter from the previous lesson: if all backend calls live in one module, a migration is a rewrite of that module plus the data copy.

A scoring checklist

Instead of arguing in the abstract, list your requirements and score each platform. The tool below is a stand-in for a decision meeting: each requirement has a weight (how much it matters to you) and a score from 0 to 2 for each platform (0 poor, 1 fine, 2 strong). The scores are our rough opinion, so change them to match your own research.

JS Stand-in: weighted requirements checklist

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Try raising the weight of "Offline-first mobile app" to 1 and see how the result changes. Honest weights are the whole point: a score only reflects what you told it.

A second stand-in shows a classic trap when comparing the two. The same question, "how many reads does this screen cost?", looks different with joins versus copies.

JS Stand-in: counting reads for a post list

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Denormalizing saves reads but makes updates harder: if the author renames themselves, every post copy must change. Neither platform removes the trade-off; they just put it in different places.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which statement about the databases is correct?

    Firestore is a NoSQL document store. Supabase is built on PostgreSQL with SQL, tables and joins.
  2. 2. What can you do with Supabase that you cannot do with Firebase?

    Supabase components are open source, so self-hosting is possible. Firebase is a closed Google platform.
  3. 3. Your app is full of many-to-many relations and needs ad hoc reports. Which is usually the better fit?

    Relational data and flexible questions are what SQL is good at.
  4. 4. Why does moving from Firebase to Supabase cost more than a library swap?

    Documents have to become tables, copied fields become joins, rules become policies, and every SDK call changes.

Summary

  • Firebase centers on the Firestore document database and Google's cloud; Supabase centers on PostgreSQL and open source parts.
  • Documents favor reads you planned for and copy data; tables favor flexible questions and joins.
  • Firebase is strong for offline mobile apps and simple realtime sync; Supabase is strong for relational data, SQL and self-hosting.
  • Migration means remodeling data and rewriting rules and calls, so keep your backend code behind an adapter.
  • Score your real requirements with weights instead of choosing by popularity.

Next: Creating Projects and Using the SDKs