What is Firebase?
Firebase is Google's platform for building web and mobile apps. It bundles together the most common things every app needs — a database, user authentication, file storage, and hosting — into a single product with a unified dashboard and SDK.
The centerpiece is Firestore, a NoSQL cloud database where your data lives in "collections" of "documents" (think of folders containing JSON files). Firestore syncs data to your app in realtime, meaning if one user changes something, every other connected device sees the update almost instantly — no polling, no manual refresh logic required.
Firebase has been around since 2011 and was acquired by Google in 2014. It's battle-tested, widely documented, and has one of the largest communities of any developer platform.
Why use it?
Firebase is especially popular for mobile apps and for developers who want to move fast. Here's what makes it appealing:
Realtime is the default. In Firestore, instead of fetching data once, you can "listen" to a document or collection. Your app UI updates automatically whenever the data changes. Building a live chat, a collaborative whiteboard, or a multiplayer feature is far simpler than on most other platforms.
Auth with five lines of code. Firebase Authentication handles the hardest parts of user management — session tokens, password hashing, OAuth flows, account linking. You call signInWithPopup(provider) and Firebase takes care of the rest.
One SDK, every platform. The same Firebase project can power your iOS app, your Android app, and your web app. Data is shared across all three automatically.
Offline support. Firestore caches data on-device and syncs changes when the user comes back online. For mobile apps with spotty connectivity, this is a significant advantage.
Free vs Paid
| Feature | Spark (Free) | Blaze (Pay as you go) |
|---|---|---|
| Firestore storage | 1 GB | $0.18/GB/month |
| Firestore reads | 50,000/day | $0.06 per 100,000 |
| Firestore writes | 20,000/day | $0.18 per 100,000 |
| Authentication | 10,000 users/month | Phone auth costs extra |
| Hosting | 10 GB storage, 360 MB/day | $0.026/GB beyond |
| Cloud Functions | Not available | Usage-based |
| File storage | 5 GB | $0.026/GB/month |
The Spark plan is free forever and covers most hobby projects comfortably. To use Cloud Functions (serverless backend logic), you must upgrade to Blaze. Blaze is pay-as-you-go, but keep an eye on your usage — Firestore read costs can add up faster than expected if you're not careful about how you query data.
Step-by-step setup
-
Create a Firebase project. Go to console.firebase.google.com, click "Add project," give it a name, and follow the prompts. You can disable Google Analytics if you don't need it.
-
Register your app. Inside your project, click the web icon (
</>). Give your app a nickname and click "Register app." Firebase will show you a config object — copy it. -
Install the SDK. In your project directory, run
npm install firebase. -
Initialize Firebase. Create a file
src/lib/firebase.jsand paste your config:import { initializeApp } from 'firebase/app' import { getFirestore } from 'firebase/firestore' import { getAuth } from 'firebase/auth' const app = initializeApp({ apiKey: "...", authDomain: "...", projectId: "...", // rest of your config }) export const db = getFirestore(app) export const auth = getAuth(app) -
Set up Firestore. In the Firebase console, go to Firestore Database > Create database. Start in test mode for development (you'll add security rules before going live).
-
Write and read data. Add a document with
addDoc(collection(db, 'tasks'), { title: 'My task' }). Read all documents withgetDocs(collection(db, 'tasks')). Listen for realtime changes withonSnapshot. -
Add authentication. Enable your sign-in methods under Authentication > Sign-in method. Then call
createUserWithEmailAndPassword(auth, email, password)to register users, andsignInWithEmailAndPasswordto log them in.
Common questions
Firebase or Supabase — which should I pick? If you're building a mobile app or need realtime sync as a core feature, Firebase is a strong default. If you're building a web app, need complex queries, or care about avoiding vendor lock-in, Supabase (which uses standard Postgres) is worth the slightly steeper learning curve.
What does "vendor lock-in" mean and should I worry? Firebase is a proprietary Google product. Your data is stored in a format that only Firebase understands, and the SDK is tightly coupled to Firebase. If you ever want to switch platforms, you'll need to write migration scripts and rewrite a significant chunk of your app. For most early-stage projects this isn't a concern — just worth knowing before you invest heavily.
How do I avoid surprise bills on the Blaze plan? Set a billing budget alert in the Google Cloud console (Firebase runs on Google Cloud). You can set it to email you when you hit $1, $5, or any amount. Firebase does not have a hard spend cap, so monitoring is important.