Firebase
A Google platform with sign-in, a realtime database and cloud functions for mobile apps.
Backend & APIsUsing since 2019 · Featured project: Hollywood Hair
- Category
- Backend & APIs
- Using since
- 2019
- Featured project
- Hollywood Hair
In practice
I pick Firebase for mobile apps that have to sign users in, sync data live and send notifications without a server of their own. At Blanket it gave me sign-in, a realtime database and cloud functions, while I keep relational data in PostgreSQL.
What is Firebase?
Firebase is a Google platform for mobile and web apps. It is made of separate services: sign-in (Authentication), document databases (Realtime Database and Firestore), cloud functions (Cloud Functions) and access rules (Security Rules).
Realtime Database stores data as JSON and syncs it live to connected clients, and the SDK persists it on disk, so the app works without a network too. The app talks to the database straight from the phone, and any server code goes into Cloud Functions, which run on Google Cloud infrastructure.
- Sign-in
- Passwords, phone, Google, Facebook
- Live database
- Realtime Database, data as JSON
- Functions
- Cloud Functions in JavaScript, TypeScript or Python
- Data access
- Server-side Security Rules
How I work with Firebase
I start with what the app has to do live and without a network. That decides which Firebase database I use, and whether I need one at all.
Sign-in
I set up Firebase Authentication with the providers the project needs. On Blanket those were Google, Apple, Facebook and email with a password, plus biometric login.
Data and rules
I keep data in Realtime Database and limit access with Security Rules, because the app connects to the database directly. I lay the data out for the queries the app actually runs.
Functions and notifications
Logic that cannot run on the phone goes into Cloud Functions. On Blanket they generated PDFs and sent push notifications, together with Notifee and Firebase Cloud Messaging.
When it fits, and when it doesn't
Firebase fits where a quick start of a mobile app matters more than owning the infrastructure.
A good fit when
- A mobile app with sign-in through Google, Apple or Facebook.
- Data that has to sync live between devices.
- A small team where nobody will look after servers.
- A product launch where the backend cannot eat the budget.
Not a fit when
- Data with many relations, reports and complex filters.
- A project where the data has to sit on your own server.
- A team that does not want to depend on a single vendor.
I keep relational data in PostgreSQL, and the differences are covered in that entry. When I want a ready backend but on Postgres, I consider Supabase: every project there gets a full Postgres database with Realtime and sign-in.
Pitfalls from real projects
Several sign-in methods in one flow
From the Blanket project
At Blanket the app had to handle sign-in through Google, Apple, Facebook and email with a password, plus biometric authentication. All of it had to fit one authorization strategy built on Firebase Auth.
Server logic without a server of your own
From the Blanket project
At Blanket, generating PDF documents and sending notifications called for a serverless backend in Cloud Functions and a push infrastructure on Notifee and Firebase Cloud Messaging.
Frequently asked questions
Planning a mobile app with a backend?
Tell me what has to work live and whether the data has relations. I will say plainly whether Firebase is enough, or whether to build on PostgreSQL from the start.