Firebase interview questions and answers for app developers
Firebase interview questions test whether you can build on a backend you do not run: modeling data in Cloud Firestore without joins, writing security rules that protect it, using Authentication tokens correctly, and moving trusted work into Cloud Functions. Expect questions on Firestore versus the Realtime Database, query and index limits, transactions, offline behavior and how reads drive cost. Senior rounds focus on rules that leak data, functions that run twice, and when a project has outgrown Firebase.
By Evin JohnPublished 8 min read
Where Firebase questions come from
Firebase is Google's app development platform: a set of managed services for authentication, databases, file storage, hosting, serverless functions, messaging and analytics, reached mostly from client SDKs. It shows up in interviews for mobile developers (Android, iOS, Flutter), front-end and full-stack developers at startups, and agencies that ship many small apps. Because clients talk to the database directly, interviewers care less about servers and more about data shape and rules. Wider Google Cloud topics such as IAM, VPCs and GKE live on GCP interview questions.
- Product knowledgeWhich Firebase service solves which problem, and how Firestore differs from the Realtime Database.
- Data modelingDesign collections for a chat, a feed or a marketplace, then answer the queries the screens need.
- Rules and authWrite or review security rules for that model and explain what a malicious client could still do.
- Scale and operationsCost spikes, a counter that falls behind, a function that fires twice, and how you would test before shipping.
Firebase fundamentals questions
| Question | What it tests | What a strong answer shows |
|---|---|---|
| What does Firebase give you, and what does it not? | Scope | Managed auth, databases, storage, hosting, functions, push messaging, remote config and analytics. You still own data design, rules, testing and any logic clients must not see. |
| Firestore or Realtime Database? | Product choice | The Realtime Database is one large JSON tree with very low-latency sync and simple queries. Firestore stores documents in collections, supports richer compound queries backed by indexes and scales more automatically. Most new projects start on Firestore. |
| What is a document and what is a collection? | Data model | A document is a set of fields with an id, with a size cap. A collection holds documents. Documents can own subcollections, which are not loaded when you read the parent. |
| get versus onSnapshot? | Read modes | A get reads once. onSnapshot keeps a listener open and pushes changes, which suits live screens but keeps costing reads as data changes. Always unsubscribe when the screen closes. |
| How does offline support work? | Client cache | The mobile SDKs cache data and queue writes by default; the web SDK can enable persistence. Listeners fire with cached data first, and metadata tells you whether a write is still pending. |
| What are Firebase Hosting and Cloud Storage for? | Services | Hosting serves static sites and single-page apps from a CDN, with rewrites to functions. Cloud Storage holds user files such as images, protected by its own rules. |
| What is the Firebase Admin SDK? | Server access | A server-side SDK with privileged credentials. It bypasses security rules, so it belongs only in trusted environments such as Cloud Functions or your own backend. |
| What is FCM? | Messaging | Firebase Cloud Messaging sends push notifications and data messages to apps. The server targets device tokens or topics, and tokens must be refreshed and cleaned up. |
| How do you read a value without downloading the whole collection? | Queries | Query with where, orderBy and limit, or read a known document by id. Firestore bills and transfers per document returned, so narrow queries matter. |
| What is Remote Config? | Feature control | Server-side parameters the app fetches to change behavior or roll out a feature to a share of users without a new release. |
Data modeling and query questions
- Why is denormalization normal in Firestore? There are no joins. You copy the fields a screen needs (an author's name on each post) so one query renders the view, and you accept keeping those copies in sync, often with a Cloud Function.
- Subcollection or top-level collection? A subcollection (posts/{id}/comments) fits data always read through its parent. A top-level collection with a parent id field fits data you query across parents. Collection group queries can search every subcollection with the same name when you need both.
- Why does a query ask you to create an index? Every Firestore query is served from an index. Single-field indexes are automatic; combining an equality filter on one field with a range or sort on another needs a composite index, and the error message links to create it.
- What query patterns are awkward? Full-text search, aggregations over large sets beyond what the built-in count and sum style aggregation queries cover, and some combinations of inequality filters. Teams add a search service or keep precomputed totals.
- How do you paginate? Order by a stable field, limit the page size and pass the last document snapshot to startAfter. Offsets still read the skipped documents, so cursors are cheaper.
- How would you model a chat app? A chats collection with member ids and a last-message summary for the inbox, and a messages subcollection per chat ordered by a server timestamp, listened to with a limit for the latest page.
- How do you keep a like counter accurate under load? Atomic increments for moderate traffic. For very hot counters, split the count across several shard documents and sum them on read, because a single document only sustains a limited write rate.
- Transaction or batched write? A transaction reads then writes and retries if the data changed underneath it. A batch writes several documents atomically without reads. Neither suits huge bulk jobs; use the Admin SDK's bulk tools for those.
import {
getFirestore, collection, doc, query, orderBy, limit,
onSnapshot, runTransaction, serverTimestamp,
} from "firebase/firestore";
const db = getFirestore();
// Live view of the newest 50 messages; call the returned function on unmount.
export function watchMessages(chatId, render) {
const q = query(
collection(db, "chats", chatId, "messages"),
orderBy("sentAt", "desc"),
limit(50),
);
return onSnapshot(q, (snap) => render(snap.docs.map((d) => ({ id: d.id, ...d.data() }))));
}
// Add a message and update the chat's summary atomically.
export async function sendMessage(chatId, uid, text) {
const chatRef = doc(db, "chats", chatId);
const msgRef = doc(collection(chatRef, "messages"));
await runTransaction(db, async (tx) => {
const chat = await tx.get(chatRef);
if (!chat.exists() || !chat.data().members.includes(uid)) throw new Error("not a member");
tx.set(msgRef, { uid, text, sentAt: serverTimestamp() });
tx.update(chatRef, { lastMessage: text, updatedAt: serverTimestamp() });
});
}Security rules and authentication questions
| Question | What it tests | What a strong answer shows |
|---|---|---|
| Why are security rules essential in Firebase? | Threat model | Clients call the database directly with your public config, so the rules are the only server-side check. Anyone can write their own client against your project. |
| What does "rules are not filters" mean? | Rule evaluation | A query fails as a whole if it could return any document the user may not read. The query must include the same constraint the rule checks, such as where authorId equals the user's id. |
| resource versus request.resource? | Write validation | resource is the document as stored; request.resource is the document as it would look after the write. Validation of new data uses request.resource. |
| How do you give admins extra rights? | Authorization | Set custom claims on the user with the Admin SDK and check request.auth.token in rules. Claims reach the client after the ID token refreshes. |
| How does a backend trust a Firebase user? | Tokens | The client sends its ID token, a short-lived signed JWT, and the server verifies it with the Admin SDK before trusting the uid inside. |
| What does App Check add? | Abuse protection | It asks the app to prove it is your genuine app on a real device or browser before backend calls are accepted. It reduces scripted abuse but does not replace rules. |
| How do you test rules? | Testing | Run them against the Emulator Suite with the rules unit-testing library, asserting both allowed and denied cases, in CI. |
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
allow read, update: if request.auth != null && request.auth.uid == userId;
}
match /posts/{postId} {
allow read: if resource.data.published == true
|| (request.auth != null && request.auth.uid == resource.data.authorId);
allow create: if request.auth != null
&& request.resource.data.authorId == request.auth.uid
&& request.resource.data.title is string
&& request.resource.data.title.size() <= 200;
allow update, delete: if request.auth != null
&& request.auth.uid == resource.data.authorId;
}
}
}A good follow-up to raise yourself: the update rule above still lets the author change authorId to someone else. Adding request.resource.data.authorId == resource.data.authorId closes that hole. Interviewers like candidates who look for what a rule still allows, not only what it blocks.
Senior Firebase and scenario questions
| Scenario | Likely cause | What a strong answer covers |
|---|---|---|
| The Firestore bill jumped after a release. | Read volume | A listener on a whole collection, a listener re-created on every render, or a screen that reads all documents to count them. Usage dashboards and query limits find it. |
| A Cloud Function sent the welcome email twice. | At-least-once delivery | Event-triggered functions can run more than once. Make them idempotent: record the event id or a sent flag in a transaction before doing the side effect. |
| Writes to one document start failing under load. | Hot document | A single counter or status document taking many writes per second. Shard it or aggregate in a scheduled function. |
| A security review found user emails readable by anyone. | Rules and data shape | Private fields stored on a publicly readable document. Rules work per document, not per field, so split private data into a separate document or subcollection. |
| Cold starts make an HTTP function slow. | Serverless startup | Large dependencies and global initialization. Trim imports, reuse clients across invocations and, if the plan allows, keep a minimum number of instances warm. |
| The team wants SQL reporting on app data. | Analytics path | Export to BigQuery (Firestore exports or the official extension, and the Analytics export) instead of running reports through client queries. See BigQuery interview questions. |
- What logic belongs in Cloud Functions rather than the client? Anything that needs secrets, trusted counts or prices, writes across users, third-party calls with keys, or validation too complex for rules.
- How do Firestore triggers work? A function subscribes to document events such as created, updated or deleted under a path pattern, and receives the before and after data. Writing back to the same document can retrigger it, so guard against loops.
- How do you handle schema changes? There is no migration system. Version fields, make readers tolerant of old shapes, and run a backfill with the Admin SDK in batches while watching quotas.
- When has a project outgrown Firebase? When core features need relational queries, heavy reporting or complex server workflows. A common path keeps Auth and moves data to a SQL database behind an API, or adds Cloud Run services beside Firebase.
- How do you work with several environments? Separate Firebase projects for development, staging and production, configs selected at build time, and the Emulator Suite for local work and tests.
Fictional example
- Interviewer
- Sellers post listings, buyers browse by category and price, and buyers can message a seller. How would you structure it in Firestore?
- Candidate
- I would start from the screens. Browsing needs listings filtered by category and sorted by price, so a top-level listings collection with category, price, status and a copy of the seller's display name, plus a composite index on category and price. Messaging gets a conversations collection keyed by listing and the two user ids, with a messages subcollection. For rules: anyone can read active listings, only the seller can update their own and cannot change sellerId, and only the two participants can read a conversation. Price changes and marking an item sold go through a Cloud Function so we can record history and notify watchers. I would write emulator tests for each rule, including a buyer trying to edit a listing.
Firebase practice plan
- Days 1 and 2: build a small app on the Emulator Suite with Auth and Firestore. Use listeners and one-time reads and notice when each fires.
- Day 3: model two features (a feed and a chat) on paper first, list each screen's query, then create the indexes they need.
- Day 4: write security rules and unit tests that try to break them: another user's data, a forged authorId, an oversized field.
- Day 5: add a Cloud Function trigger that keeps a denormalized field in sync, then make it idempotent.
- Day 6: read your usage numbers after a scripted session and explain where the reads came from.
- Day 7: mock interview: design a model and rules out loud in twenty minutes, then defend one trade-off.
Firebase questions often lead elsewhere in the loop. Custom backends come up in Express.js interview questions, and security reviewers who probe open rules appear in ethical hacking interview questions.
Design answers for Firebase are judged on whether you started from the screens and the rules, which is easy to forget once you start talking about collections. Natively, an AI interview assistant for Mac and Windows, records a written transcript of your mock design round on your computer so you can review the order you covered things in. In practice it can read a rules file or a data model from a screenshot and point out gaps, and with Pro or the free trial it can use the résumé and job description you add to match the stack. Notes are kept with each session.
Questions people ask
What Firebase questions are asked in interviews?
Firestore versus Realtime Database, documents, collections and subcollections, denormalized data models, composite indexes, listeners versus one-time reads, security rules, Authentication and custom claims, the Admin SDK, Cloud Functions triggers and cost control.
What is the difference between Firestore and Realtime Database?
The Realtime Database stores one JSON tree with simple queries and very fast sync. Firestore stores documents in collections, supports compound queries backed by indexes, and scales more automatically, which is why most new projects choose it.
How do Firebase security rules work?
Rules run on Google's servers for every client read and write, checking request.auth, the stored document and the incoming data. They are not filters: a query must only ask for documents the rules allow, or it fails.
How should I prepare for a Firebase interview?
Build a small app on the Emulator Suite, model two features from their screens, write rules with tests that try to break them, add an idempotent Cloud Function, and practice explaining where your reads and costs come from.
Where to go next
Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.
Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.
