Firestore Listeners vs WebSockets: How Real-Time Updates Actually Work

Firestore has one of the most convenient real-time APIs in web and mobile development. We write a listener: import { collection, onSnapshot, query, where } from "firebase/firestore"; const q = query( collection(db, "messages"), where("roomId", "==", "general") ); const unsubscribe = onSnapshot(q, (snapshot) => { snapshot.docChanges().forEach((change) => { console.log(change.type, change.doc.id, change.doc.data()); }); }); After that, the UI updates whenever matching documents are added, modified, or removed. It feels similar to a WebSocket because the browser receives real-time updates without manually polling. But Firestore listeners and WebSockets are not the same abstraction. ...

May 3, 2026 · 13 min · Nitin