Firebase
- Pronunciation
- FYR-bayss
In short
Firebase is Google's platform that gives web and mobile apps a hosted database, authentication, storage, hosting and functions without managing a backend.
What is Firebase?
Firebase started in 2011 as a real-time database startup and was acquired by Google in 2014. It grew into a backend-as-a-service: instead of writing and running your own server, the app talks to Firebase directly through its SDKs for the web, iOS, Android and Flutter.
Its main database today is Cloud Firestore, a NoSQL document database where data lives in collections of documents. Clients can subscribe to a query and receive updates in real time as the data changes, and offline support lets mobile apps keep working without a connection. The original Realtime Database, one big JSON tree, is still offered.
Around the database are Firebase Authentication, with email, phone and social logins, Cloud Storage for files, Hosting for static sites, Cloud Functions for server-side code that runs on events, and Cloud Messaging for push notifications. Because clients access data directly, Security Rules decide who may read and write each document.
A common misconception is that Firebase needs no security work because there is no server. Badly written Security Rules are a frequent cause of data leaks, since anyone can call the database with your app's public configuration. Costs also scale with every read and write, so inefficient queries can become expensive.
Key takeaways
- Firebase is Google's backend platform for web and mobile apps.
- Cloud Firestore is a NoSQL document database with real-time updates.
- It also offers authentication, storage, hosting, functions and push messages.
- Clients talk to it directly, so Security Rules protect the data.
- Pricing follows reads and writes, so query design affects cost.
Example
import { initializeApp } from "firebase/app";
import { getFirestore, collection, addDoc, query, where, onSnapshot } from "firebase/firestore";
const app = initializeApp({ projectId: "my-app", apiKey: "public-web-key" });
const db = getFirestore(app);
await addDoc(collection(db, "messages"), { room: "general", text: "Hello!", sentAt: Date.now() });
// Real-time: the callback runs again whenever matching documents change
const general = query(collection(db, "messages"), where("room", "==", "general"));
onSnapshot(general, (snapshot) => {
snapshot.docChanges().forEach((change) => console.log(change.type, change.doc.data().text));
});Readers ask
Is Firebase a database?
It is a platform that includes databases, Cloud Firestore and the Realtime Database, along with authentication, storage, hosting and other backend services.
What is the difference between Firestore and the Realtime Database?
The Realtime Database stores everything as one large JSON tree and is very low-latency. Firestore organizes data into collections and documents, supports richer queries and scales further, and is the recommended choice for most new apps.
Is the Firebase API key a secret?
No. The web configuration, including the API key, is meant to be public and only identifies your project. Access is controlled by Security Rules and App Check, not by hiding the key.
Often compared
See also
- NoSQLDatabases, p. 29NoSQL is a family of databases that store data in models other than relational tables, such as documents, key-value pairs, wide columns, or graphs.
- Document DatabaseDatabases, p. 15A document database is a NoSQL database that stores each record as a self-contained document, usually JSON-like, whose fields can differ from record to record.
- ServerlessDevOps & Cloud, p. 47Serverless is a cloud model in which the provider runs your code on demand, manages all the servers, scales automatically, and bills only for actual use.
- AuthenticationSecurity, p. 2Authentication is the process of verifying that a user, device, or service really is who it claims to be, for example by checking a password or passkey.
- SupabaseDatabases, p. 45Supabase is an open-source backend platform built on PostgreSQL that gives an app a database, authentication, storage, real-time updates and instant APIs.
- WebSocketWeb Development, p. 61WebSocket is a protocol that keeps a single connection open between a browser and a server so both sides can send each other messages instantly at any time.
Spotted a mistake or something missing on this page?Suggest an edit