IndexedDB Transactions and Storage Quotas vs Local-First Sync & CRDTs
IndexedDB persists single-device B-tree records, whereas CRDTs merge concurrent multi-device edits deterministically.
Structured Comparison Matrix
| Dimension | IndexedDB Transactions and Storage Quotas | Local-First Sync & CRDTs |
|---|---|---|
| Mental Model | Transactional client-side B-tree object store whose transactions auto-commit on microtask drain and whose storage limits depend on origin-wide disk quotas. | Persists every edit locally in IndexedDB/OPFS at 0 ms network wait and uses Conflict-free Replicated Data Types (CRDTs) so offline peers merge deterministically. |
| Maturity & Domain | Baseline · Widely · Web APIs Chrome 24+ · Firefox 16+ · Safari 10+ | Experimental · State & Architecture Chrome 24+ (IndexedDB) / OPFS 102+ · Firefox 16+ (IndexedDB) / OPFS 111+ · Safari 10+ (IndexedDB) / OPFS 15.2+ |
| Prerequisites | ||
| When Not to Use | When not to use IndexedDB: For sequential binary file streaming, SQLite page files, or append-only logs, use OPFS instead of serializing chunks into B-tree records; for multi-tab mutexes or offline conflict resolution, pair it with BroadcastChannel & Web Locks and Local-First Sync & CRDTs. | When not to use CRDTs: For strict financial ledgers, inventory counts, or unique-username claims where two offline writes cannot both succeed, use server-authoritative transactions instead. |
Engine Mechanics & Trade-Offs
IndexedDB serializes overlapping readwrite transactions per object store and auto-commits any transaction left idle across an async await boundary.
Key Pitfalls: Awaiting non-IDB promises inside a transaction: await fetch() or await new Promise(setTimeout) closes the transaction and throws TransactionInactiveError on the next write. Large structuredClone payloads on the main thread: Writing 50 MB blobs in one store.put() stalls the UI thread; run heavy writes in a Dedicated Web
Writes mutations locally first at 0ms network wait, encoding operations with causal/Lamport clocks so offline peers merge deterministically upon reconnection.
Key Pitfalls: Unbounded tombstone growth: Deleted characters in sequence CRDTs stay as invisible tombstones so concurrent edits know where they sat; without snapshot compaction, a 10 KB note can bloat to 50 MB of history. Wall-clock Date.now() tie-breakers: Relying on a user's system clock for Last-Write-Wins lets a laptop with a cl