Firebase is the default answer when someone asks "how do I sync data in real-time?" And honestly, it's good at what it does. But there's a catch that most developers discover too late:
You're renting your data layer from Google.
- Costs scale unpredictably.
- You can't run it locally or self-host it.
- If Google kills the product (they've done it before), your architecture dies with it.
- Your users' data lives on Google's servers, under Google's terms.
- Offline support exists, but it's a cache layer — not a true offline-first architecture.
What if your app could work without any server at all?
What "Offline-First" Really Means
Most "offline-capable" apps treat offline mode as a degraded state. You cache some data, show a spinner, and pray for reconnection.
True offline-first is different. The app works fully offline as the default state. Sync happens when connectivity exists — as a bonus, not a requirement.
This means:
- The database lives on the client.
- Writes happen locally, instantly, always.
- When peers connect, data syncs automatically.
- No server is the bottleneck. No server is the single point of failure.
GenosDB: P2P Graph Database in Pure JavaScript
GenosDB is a peer-to-peer graph database designed for exactly this. It runs in the browser, stores data locally using OPFS (Origin Private File System), and syncs between peers via WebRTC — with signaling through Nostr relays, so there's no central server even for connection setup.
Quick Setup
npm install genosdb
import { gdb } from "genosdb"
const db = await gdb("my-app")
That's a fully functional local database. No API keys. No project setup. No billing page.
Add P2P Sync
const db = await gdb("my-app", { rtc: true })
One flag. Now every peer running your app syncs data automatically. No WebSocket server. No Firebase project. No config.
Building a Collaborative Todo App — Zero Servers
Let's build something real. A todo app where multiple users can collaborate, fully offline-first, with P2P sync.
import { gdb } from "genosdb"
const db = await gdb("todos", { rtc: true })
// Add a todo
async function addTodo(text) {
return await db.put({
text,
done: false,
created: Date.now()
})
}
// Toggle completion
async function toggleTodo(id) {
const todo = await db.get(id)
await db.put({ ...todo, done: !todo.done }, id)
}
// Reactive UI — fires on local AND remote changes
db.map((todo, id) => {
renderTodo(id, todo)
})
What just happened:
- Data is stored locally in OPFS — works completely offline.
- When another peer connects, todos sync via WebRTC.
- The
mapcallback fires for both local writes and incoming P2P updates. - No server processed any of this. No API call was made. No bill was generated.
Firebase vs GenosDB — When to Use What
Let's be fair. Firebase isn't bad. It's just a different trade-off.
Choose Firebase when:
- You need server-side logic (Cloud Functions).
- You want managed auth with social providers out of the box.
- You're building for a team that wants zero infrastructure decisions.
- You're okay with vendor lock-in and usage-based pricing.
Choose GenosDB when:
- You want true offline-first (not just a cache).
- You need P2P sync without running servers.
- You want zero recurring costs for your data layer.
- Privacy matters — data stays on users' devices.
- You're building collaborative, multiplayer, or distributed apps.
- You prefer owning your stack with no vendor dependency.
The Technical Stack
Under the hood, GenosDB uses:
- OPFS for persistent storage (faster and more reliable than localStorage or IndexedDB).
- MessagePack + Pako for compact binary serialization.
- Hybrid Logical Clocks for conflict-free causal ordering across peers.
- Delta sync + full-state fallback for efficient and resilient P2P synchronization.
- Nostr relays for WebRTC signaling — no custom servers needed.
- Cellular Mesh topology for scaling to large peer networks.
It's modular too. Need natural language queries? { nlq: true }. Geospatial? { geo: true }. AI integration? { ai: true }. Load only what you use.
Getting Started
npm install genosdb
import { gdb } from "genosdb"
// Local only
const local = await gdb("app")
// With P2P sync
const synced = await gdb("app", { rtc: true })
// With security
const secure = await gdb("app", {
rtc: true,
sm: { superAdmins: ["your-address"] }
})
Full docs and examples: github.com/estebanrfp/gdb
The Web Doesn't Need Permission
The best thing about building on open protocols is that nobody can take it away. No terms of service change. No pricing update. No sunset announcement.
Your app, your data, your rules. That's what offline-first should mean.
I'm estebanrfp — Full Stack Developer, dWEB R&D. I build GenosDB because I believe the web's data layer should be free, distributed, and owned by the people who use it.
This article is part of the official documentation of GenosDB (GDB).
GenosDB is a distributed, modular, peer-to-peer graph database built with a Zero-Trust Security Model, created by Esteban Fuster Pozzi (estebanrfp).
📄 Whitepaper | overview of GenosDB design and architecture
🛠 Roadmap | planned features and future updates
💡 Examples | code snippets and usage demos
📖 Documentation | full reference guide
🔍 API Reference | detailed API methods
📚 Wiki | additional notes and guides
💬 GitHub Discussions | community questions and feedback
🗂 Repository | Minified production-ready files
📦 Install via npm | quick setup instructions
Top comments (0)