Firebase interview questions

25 questions from the Firebase course, each with the correct answer and an explanation. Try to answer before you open the answer.

Firebase Foundations

1. Which Firebase product is a document database with realtime listeners and rich queries?

  1. Remote Config
  2. Cloud Messaging
  3. Cloud Firestore
  4. Hosting
Show answer

Answer: Cloud Firestore

Firestore stores documents in collections.

Lesson: What Firebase Is

2. In a typical Firebase app, what protects Firestore data from a user who copies your web config?

  1. Security Rules evaluated on every client request
  2. Keeping the API key secret
  3. Minifying the JavaScript bundle
  4. Using HTTPS only
Show answer

Answer: Security Rules evaluated on every client request

The config is public; rules are the boundary.

Lesson: The Client SDK Model and Why Rules Matter

3. Which statement about the Firebase web config is correct?

  1. It contains the Admin SDK private key
  2. It must be stored only on the server
  3. Anyone with it can bypass Security Rules
  4. It identifies the project and is safe to include in client code
Show answer

Answer: It identifies the project and is safe to include in client code

Access is controlled by rules and Auth, not by hiding the config.

Lesson: Project Setup and Config

Firebase Authentication

4. Which function completes passwordless sign-in after the user opens the emailed link?

  1. createUserWithEmailAndPassword
  2. signInWithEmailLink
  3. sendPasswordResetEmail
  4. signInAnonymously
Show answer

Answer: signInWithEmailLink

The link carries a one-time code in the URL.

Lesson: Email/Password and Email Link Sign-in

5. Why link an anonymous account instead of signing in fresh with Google?

  1. Anonymous accounts cannot be deleted
  2. The user keeps the same uid, so data written as a guest stays theirs
  3. Linking is required to use Firestore
  4. Google sign-in does not create a uid
Show answer

Answer: The user keeps the same uid, so data written as a guest stays theirs

Linking adds a credential to the existing user.

Lesson: OAuth Providers and Anonymous Auth

6. Where can custom claims be set?

  1. In the web config object
  2. From any client with updateProfile
  3. Inside Security Rules
  4. Only from trusted code using the Admin SDK
Show answer

Answer: Only from trusted code using the Admin SDK

Clients must not grant themselves roles.

Lesson: Auth State, ID Tokens and Custom Claims

Firestore Data Modelling

7. What happens to a document's subcollections when the document is deleted from the client?

  1. They remain and must be deleted separately
  2. They are deleted automatically
  3. They move to the parent collection
  4. The delete is rejected
Show answer

Answer: They remain and must be deleted separately

Subcollections are independent of the parent document's existence.

Lesson: Documents, Collections and Subcollections

8. Where should an ever-growing list of comments on a post live?

  1. In the post's title field as JSON
  2. In an array field on the post document
  3. In a subcollection with one document per comment
  4. In custom claims
Show answer

Answer: In a subcollection with one document per comment

Documents have size limits; collections do not grow inside one document.

Lesson: Modelling for Queries

9. What does setDoc do without the merge option when the document already exists?

  1. Appends a new version
  2. Fails with not-found
  3. Overwrites the whole document with the new data
  4. Merges only changed fields
Show answer

Answer: Overwrites the whole document with the new data

Use { merge: true } or updateDoc to change some fields.

Lesson: Reading and Writing Documents

Querying Firestore

10. A query fails with an error containing a console link. What is the most likely cause?

  1. A required composite index does not exist yet
  2. The API key is invalid
  3. The collection is empty
  4. Security Rules are disabled
Show answer

Answer: A required composite index does not exist yet

Multi-field queries need composite indexes.

Lesson: Queries and Composite Indexes

11. Why prefer startAfter over skipping N documents?

  1. Cursors bypass Security Rules
  2. startAfter works without any ordering
  3. Offsets are not allowed in JavaScript
  4. Skipped documents are still read and billed, while cursors read only the page
Show answer

Answer: Skipped documents are still read and billed, while cursors read only the page

Cursors are cheaper and stable.

Lesson: Pagination With Cursors

12. What does onSnapshot return?

  1. A promise of the first snapshot only
  2. A function that removes the listener
  3. The document id
  4. A transaction object
Show answer

Answer: A function that removes the listener

Call it when the view is destroyed.

Lesson: Realtime Listeners and Offline Persistence

Security Rules

13. A query for all posts is rejected even though rules allow reading posts where authorId == request.auth.uid. Why?

  1. Queries never pass rules
  2. Rules are not filters; the query must itself constrain authorId to the user's uid
  3. list operations are always denied
  4. The rules need rules_version 3
Show answer

Answer: Rules are not filters; the query must itself constrain authorId to the user's uid

Rules check whether every possible result is allowed.

Lesson: Rules Language Basics

14. Which expression stops an update from changing fields other than displayName and bio?

  1. allow update: if true
  2. resource.data.keys().size() == 2
  3. request.auth.token.admin == true
  4. request.resource.data.diff(resource.data).affectedKeys().hasOnly(['displayName', 'bio'])
Show answer

Answer: request.resource.data.diff(resource.data).affectedKeys().hasOnly(['displayName', 'bio'])

diff().affectedKeys() lists changed fields.

Lesson: Common Rule Patterns

15. Which helper asserts that an operation is denied by rules?

  1. assertFails
  2. assertSucceeds
  3. withSecurityRulesDisabled
  4. onSnapshot
Show answer

Answer: assertFails

Test denials as carefully as approvals.

Lesson: Testing Rules With the Emulator Suite

Storage and Cloud Functions

16. Which rule condition limits uploads to images?

  1. request.auth.token.image == true
  2. resource.data.type == 'image'
  3. request.resource.contentType.matches('image/.*')
  4. request.time < timestamp.date(2030, 1, 1)
Show answer

Answer: request.resource.contentType.matches('image/.*')

request.resource describes the incoming file.

Lesson: Cloud Storage Uploads and Rules

17. Why must a callable function check request.auth and validate data itself?

  1. Rules run after the function
  2. Callable functions cannot read auth
  3. The Admin SDK bypasses Security Rules, so the function is the only guard
  4. HttpsError disables validation
Show answer

Answer: The Admin SDK bypasses Security Rules, so the function is the only guard

Trusted code carries the responsibility.

Lesson: Cloud Functions and the Admin SDK

18. Where should a third-party API key used by a function be stored?

  1. In Secret Manager via defineSecret
  2. In the client web config
  3. In a public Firestore document
  4. Hard-coded in index.ts
Show answer

Answer: In Secret Manager via defineSecret

Secrets stay server-side and out of source control.

Lesson: Scheduled Functions and Secrets

Hosting and App Features

19. What is a Hosting preview channel?

  1. A push notification topic
  2. A second Firestore database
  3. A Remote Config parameter
  4. A temporary URL for a build that can expire automatically
Show answer

Answer: A temporary URL for a build that can expire automatically

Previews separate review from production.

Lesson: Hosting, App Hosting and Preview Channels

20. Who should send FCM messages to other users' devices?

  1. Any client directly with the web config
  2. Trusted server code using the Admin SDK
  3. Security Rules
  4. Remote Config
Show answer

Answer: Trusted server code using the Admin SDK

Sending requires server credentials.

Lesson: Cloud Messaging (Push) Overview

21. Why are in-app defaults important for Remote Config?

  1. Defaults encrypt the values
  2. The app must behave sensibly before or without a successful fetch
  3. Fetches are impossible without them
  4. Defaults replace Security Rules
Show answer

Answer: The app must behave sensibly before or without a successful fetch

Networks fail; defaults keep the app working.

Lesson: Remote Config, Analytics and Crashlytics

Firebase in Production

22. Why must a transaction function avoid side effects like sending an email?

  1. Transactions run only on the emulator
  2. Transactions cannot call functions
  3. Emails are blocked by rules
  4. It may be retried several times if data changes before commit
Show answer

Answer: It may be retried several times if data changes before commit

Retries would repeat the side effect.

Lesson: Transactions and Batched Writes

23. What is the main billing unit to watch in Firestore client code?

  1. Document reads, writes and deletes
  2. Lines of JavaScript shipped
  3. Number of collections
  4. Length of field names only
Show answer

Answer: Document reads, writes and deletes

Query design drives read counts.

Lesson: Cost and Performance Control

24. How should a CI pipeline authenticate the Firebase CLI?

  1. With the public web API key
  2. With a developer's personal password
  3. With a Google Cloud service account
  4. It needs no authentication
Show answer

Answer: With a Google Cloud service account

Service accounts are auditable and revocable.

Lesson: Emulators and CI Deploys

25. Which is a common reason to choose Supabase or a SQL backend over Firestore?

  1. Wanting managed authentication
  2. Needing realtime listeners
  3. Highly relational data that benefits from joins and SQL queries
  4. Deploying a static site
Show answer

Answer: Highly relational data that benefits from joins and SQL queries

Firestore has no joins.

Lesson: Trade-offs and a Firebase Checklist

← Back to the course