Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 31 ยท Backend as a Service

What Is a Backend as a Service?

Learn what a Backend as a Service replaces, what you trade away, how pricing and lock-in work, and how this track teaches Firebase and Supabase.

Almost every app needs the same back-of-house parts: a way to sign users in, a database to keep their data, a place for uploaded files, and a little server code that runs when something happens. Writing all of that yourself takes weeks before the first real feature exists. A Backend as a Service (BaaS) is a hosted product that gives you those parts ready-made, behind an SDK you call straight from your web or mobile app.

This track teaches the two most popular choices: Firebase (from Google) and Supabase (built on PostgreSQL, open source). You will learn what each one offers, how to keep it secure, and how to design data for it. If you want to build your own server instead, the Node.js tutorial and the SQL tutorial cover that path, and a BaaS is just a shortcut over the same ideas.

What a BaaS replaces

Think of a classic backend as four jobs. A BaaS offers a managed version of each.

Four jobs a BaaS takes over

Authentication Sign-up, sign-in, passwords, OAuth, tokens.
Database Stored data with queries and live updates.
File storage Uploads, downloads, private links.
Functions Your own code, run on events or requests.

You still write the app. You skip most of the plumbing.

1 / 2

The key difference from a normal backend is who talks to the database. In a traditional app, only your server touches the database, and the browser asks your server for things. In a BaaS, the browser or phone app talks to the database directly through the SDK. Because anyone can open the developer tools and read your app's keys, the protection moves into the data service itself. Firebase calls this security rules; Supabase uses PostgreSQL row level security policies. You will meet both in the Firestore security rules and row level security lessons.

flowchart LR
    A["Your app<br/>(browser or phone)"] -->|"SDK call + user token"| B["BaaS<br/>auth, rules, database"]
    B -->|"allowed rows only"| A
    B --> C["Storage"]
    B --> D["Functions"]

The app calls the BaaS directly. The rules inside the service decide what each user may see.

The Firebase product map

Firebase is not one database but a family of products on Google Cloud. Grouped by job:

  • Build: Authentication, Cloud Firestore, Realtime Database, Cloud Storage, Hosting, Cloud Functions and Data Connect (Postgres).
  • Run and improve quality: Crashlytics, Performance Monitoring, App Check, App Distribution and Test Lab.
  • Grow: Analytics, Remote Config, A/B Testing and Cloud Messaging.

Strengths: real-time sync out of the box, one SDK for web, iOS, Android and Flutter, serverless execution, fast prototyping, a free tier and tight Google Cloud integration. Weaknesses: a proprietary document model that is hard to migrate away from, limited query power compared with SQL, costs that scale with reads, and security that depends on rules you must write correctly (a badly configured project can leak data). Choose it for app speed and real-time features, and look at Supabase if you prefer SQL and open source. Two products get their own lessons later: the Realtime Database and Analytics and monitoring.

Trade-offs against your own server

A BaaS is not always better. It is a trade.

What you gain

  • Speed to a first version. Auth and a database can work in an afternoon.
  • Less to operate. No servers to patch, no backups to schedule, no scaling plan on day one.
  • Realtime built in. Live updates to every connected client are a feature, not a project.
  • Generous free tiers that let you build and test without a credit card.

What you give up

  • Control. You work inside the platform's limits: query shapes, request sizes, regions, timeouts.
  • Predictable costs. You pay for usage, so one badly written screen can multiply your bill.
  • Business logic in the open. Anything that must be trusted needs rules or a server function, because the client cannot be trusted.
  • Portability. Which brings us to lock-in.

Lock-in

Lock-in means how expensive it is to leave. It comes in layers.

  1. Data format. Firestore stores documents in a proprietary model, so moving to another database means redesigning your data. Supabase data is plain PostgreSQL, which you can dump and restore anywhere.
  2. Client code. Every SDK call (getDoc, .from('todos').select()) is vendor-specific. A thin wrapper of your own, an adapter, keeps most of the app unaware of the vendor.
  3. Rules and policies. They are written in the platform's own language and must be rewritten on migration.
  4. Hosting. Supabase can be self-hosted because it is open source. Firebase cannot.

The practical advice: put every call to the backend behind your own small interface. The stand-in below does exactly this, and the Todo project uses the same trick to run on both platforms.

Pricing models

Both services have a free tier and then charge by usage, but they count different things.

  • Firebase bills mostly by operations: document reads, writes and deletes, plus stored data, bandwidth and function invocations. A screen that loads 500 documents costs 500 reads every time it opens.
  • Supabase bills mostly by project: a plan includes a database size, bandwidth, storage and number of monthly active users, with overages beyond. Queries themselves are not billed one by one; the database size and compute are.

Prices and limits change, so check the current pricing pages before you decide. What does not change is the habit: look at what is billed per unit, and design so the common screen touches few units.

How this track works

The real Firebase and Supabase services need an account, a project and network access to a running service. This website cannot offer any of that, so every lesson works in two layers:

  1. Real code, read-only. SDK calls, rules, SQL and CLI commands appear in plain code blocks. You can copy them into your own project. They were written to be accurate, but they do not run here.
  2. Runnable stand-ins. A stand-in is a small program of ours that imitates the idea inside the service: a store, a query builder, a token signer, a rule checker. You can run and edit these in the page. They teach the mechanics honestly, but they are not the real services and miss many details such as networking, scale and exact error messages. Every lesson says which part is real and which is the stand-in.

A tiny backend with a client SDK

Here is a first stand-in. The FakeBackend class plays the role of the cloud service: it keeps tables in memory and checks a user token. The createClient function plays the SDK. Notice how the app code never touches the tables directly. It only calls the client, which is how real SDKs feel.

JS Stand-in: an in-memory backend and client SDK

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

No output.

Ada and Bo use the same table, yet each sees only their own rows, because the service filters by the token. That separation is exactly what security rules and row level security do in the real products.

Vendor independence with an adapter

A second stand-in shows the lock-in advice. The app depends on a small TodoStore shape. Two different "vendors" implement it, and the app code is identical for both.

JS Stand-in: one app, two interchangeable backends

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

No output.

Write your own tiny adapter even if you plan to stay with one vendor. It also makes the app easy to test, because a fake in-memory store replaces the network.

When a BaaS is a good fit

  • Prototypes, startups and side projects that must ship fast.
  • Apps with a lot of per-user data and live updates: chat, collaboration, dashboards.
  • Mobile apps, where running your own API is extra work.
  • Small teams without a dedicated backend developer.

Consider your own server when you have complex business workflows, heavy reporting across all users' data, strict data residency or compliance rules, or you need full control over costs at large scale. Many real products mix both: a BaaS for auth and storage plus a custom service for the hard parts.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is the main difference in how the client talks to data in a BaaS compared with a classic backend?

    In a BaaS the client SDK talks to the data service directly, so the rules inside the service must protect the data.
  2. 2. Why is it wise to hide BaaS calls behind your own adapter interface?

    An adapter keeps vendor-specific calls in one place, so changing or faking the backend touches little code. It does not replace security rules.
  3. 3. Which statement about the runnable examples in this track is true?

    The site cannot run the real services, so stand-ins show the mechanics and each lesson says what is real and what is imitation.
  4. 4. A screen that loads 500 documents on every visit is most likely to hurt which kind of bill?

    With per-operation pricing such as Firestore reads, each document loaded counts, so heavy screens multiply the bill.

Summary

  • A BaaS gives you managed authentication, a database, file storage and functions behind an SDK that your client calls directly.
  • Because clients are public, protection lives in the service as security rules (Firebase) or row level security (Supabase).
  • You trade control, predictable costs and portability for speed and less operations work.
  • Lock-in has layers: data format, SDK calls, rules and hosting. An adapter of your own reduces it.
  • This track shows real code read-only and teaches the mechanics with runnable stand-ins that are not the real services.

Next: Firebase vs Supabase: Choosing