skip to content

Firebase

Google's backend-as-a-service for mobile and web apps: Firestore, Authentication, Security Rules, Cloud Functions, Storage, Hosting and FCM. Asked where an app ships without its own server.

on this pageshow

explore

questions

page 2 of 2

In a Firestore task app, every task change also updates an openTaskCount field on the project document; why does this degrade as the team grows, and what do you change?

level: seniorimportance: should knowfreq 42%

basics

~20 s

Every task change funnels a write into one project document, and a single Firestore document sustains only a limited write rate, so contention brings latency, retries and errors. Use FieldValue.increment, shard the counter across documents, or compute it with count().

open as a page

In Firestore Security Rules for a classroom app, when should a teacher check read a custom claim from request.auth.token rather than call get() on a roles document?

level: seniorimportance: should knowfreq 42%

basics

~20 s

Use a custom claim for a coarse, slow-changing role such as teacher: it costs no read but stays stale until a new ID token. Use get() or exists() for live per-class membership, paying a billed read and a capped lookup count.

open as a page

Why does a Cloud Function behind a Firebase Hosting rewrite run on every request and never see the session cookie, and what fixes both?

level: seniorimportance: should knowfreq 28%

basics

~20 s

Hosting's CDN does not cache function responses unless they say so, and it strips cookies from requests except one named __session. Send Cache-Control: public with s-maxage for shareable pages, and rename the session cookie to __session.

open as a page

A user uploads a 300 MB recipe video with the Firebase Storage Android SDK and Android kills the process halfway; how do you resume without re-sending the first half?

level: seniorimportance: should knowfreq 30%

basics

~20 s

Save the upload snapshot's uploadSessionUri to persistent storage once it appears, then after the restart call putFile(uri, metadata, sessionUri). The SDK asks the server how many bytes arrived and continues from there; sessions last a week.

open as a page

As the lead on an Android app built on Firebase, how do you decide which writes go straight from the client under Security Rules and which go through Cloud Functions?

level: principalimportance: should knowfreq 30%

basics

~20 s

Let the client write directly where Security Rules can validate the change from the request alone; route a write through a callable when it needs secrets, hidden data or cross-document invariants, and deny that direct path in rules. Triggers handle consequences.

open as a page

How do Firebase Authentication custom tokens let users of an existing login system sign in to Firebase from an Android app?

level: middleimportance: nice to knowfreq 28%

basics

~10 s

Your server validates the user with its own system, then mints a signed JWT with the Admin SDK's createCustomToken(uid). The app exchanges it with signInWithCustomToken and gets an ordinary Firebase session for that uid.

open as a page

showing 31–36 of 36