Backend-as-a-Service: Firebase & Supabase

Ship features fast with managed databases, auth, storage and functions from Firebase or Supabase, and secure them with rules.

Intermediate · about 8 hours · difficulty 3/5

Learn first: Networking Clients & Server-state Caching

Backend-as-a-Service (BaaS) platforms give mobile developers a database, authentication, file storage and serverless functions without running servers. They are ideal for prototypes, hackathons and many production apps.

Firebase

  • Firestore: a NoSQL document database with realtime listeners and offline persistence.
  • Authentication, Cloud Storage, Cloud Functions, Remote Config, plus Crashlytics and Analytics.
  • Use React Native Firebase, FlutterFire, or the native SDKs.

Supabase

  • Postgres with an auto-generated API, realtime subscriptions, auth, storage and Edge Functions.
  • Relational data and SQL skills carry over; it is open source and self-hostable.

Security is on you

With BaaS, the client talks directly to the database, so security rules (Firestore rules) or Row Level Security policies (Supabase) are your only protection. An API key in the app is not a secret; rules decide what each user can read and write. Test rules with the emulator or policy tests.

Trade-offs

Vendor lock-in, pricing that scales with reads, and data modelling constraints (Firestore) are real. Keep a thin data layer so you could migrate later.

Good enough to move on: your app stores per-user data in Firebase or Supabase, and a second test user cannot read the first user's data.

Key concepts

  • Firestore documents and collections
  • Supabase Postgres and client
  • Realtime listeners
  • File storage
  • Security rules and Row Level Security
  • Cloud Functions or Edge Functions
  • Local emulators

Mini project

Build a shared grocery list app with realtime updates between two phones, backed by Firestore or Supabase with rules restricting access to list members.

Check yourself

If your Firebase config and API key are visible inside the app bundle, what actually protects your data?

Free resources