ArchitectureLive

Offline Data + Sync

Two parallel implementations of the same problem — persisting data offline and syncing it once the connection returns — using IndexedDB and OPFS with wa-sqlite (real SQLite compiled to WebAssembly, running inside a Web Worker via asynchronous message passing). The queue of pending notes is resolved by the Service Worker's Background Sync API as soon as connectivity returns, even with the tab closed; the OPFS worker reconciles its own state once it receives the sync-completed notice. The Storage API exposes the real storage quota and protects data from cache eviction once persistence is granted.

OPFS IndexedDB wa-sqlite WebAssembly Web Workers Sync Storage API

Technologies

  • OPFS
  • wa-sqlite
  • Web Workers
  • IndexedDB
  • Storage API
  • Background Sync API

Architecture

  • OPFS
  • SQL
  • WebAssembly
  • Web Worker
  • IndexedDB
  • Background Sync Queue

Concepts

  • OPFS
  • SQL over WebAssembly
  • Worker thread isolation
  • Asynchronous worker messaging
  • Main thread
  • Secondary thread
  • Persistence
  • Sync queue

Demo area

The demo is 100% functional — try it now.