Build Offline Sync Engine on nextjs-dexie-postgres

Local-first app core — client store, sync protocol, per-field LWW conflict resolution, offline queue, and a schema-migration story that survives queued mutations — an agent-executable blueprint with a runnable convergence proof.

This build pack is pinned for nextjs-dexie-postgres, with verification pending. No pass rate is published until the harness runs it.

Coming soon — $99

nextjs-dexie-postgres versions lock

node24.18.1
next16.2.12
react19.2.8
react-dom19.2.8
typescript6.0.3
dexie4.4.4
zod4.4.3
pg8.22.0
@electric-sql/pglite0.5.4
tsx4.23.1
@types/node26.1.2
@types/pg8.20.0
@types/react19.2.17
@types/react-dom19.2.4
tailwindcss4.3.3
@tailwindcss/postcss4.3.3
clsx2.1.1
tailwind-merge3.6.0

What you get

Features:

  • Offline-first CRUD: create/edit/delete work with zero network; instant local apply, background sync on reconnect
  • Per-field last-write-wins conflict resolution on Hybrid Logical Clocks — deterministic, identical on every device
  • Field merge: concurrent edits to different fields of the same record both survive
  • Replicated deletes with tombstones, 90-day retention, server compaction, forced-resync recovery for stale clients
  • Cursor-paginated pull + batched, blindly-retryable (idempotent) push over two HTTP endpoints
  • Clock-skew defense: 5-minute server drift gate + automatic outbox re-stamping
  • Versioned wire schema: queued offline mutations survive app upgrades via client-side outbox migration; the server accepts only the current wire version (HTTP 426 otherwise)
  • Generic engine (any table/row/column) with pluggable storage (IndexedDB via Dexie in the browser, in-memory for tests)
  • Runnable acceptance harness (`verify.sh`) covering conflicts, deletes, pagination, skew, migration, and reset — exit 0 = correct build

Screens (demo notes app, Tailwind 4 + shadcn/ui conventions):

  • **Notes** (`/`) — note list with inline title/body editing, add and delete, online/offline badge, pending-changes count, manual Sync button (auto-sync every 15 s and on reconnect)

Build budget: **expected 2 sessions on a $20/mo plan** (Claude Pro or equivalent) — one build session, one verify/fix session; allow a third if the fix pass runs long. The binding constraint is **Opus-tier usage, not token volume**: three tasks route to `claude-opus-5` (T4 server core, T5 engine, T8 verify/fix), and Pro's Opus allowance is what forces the session split. Everything else runs on Sonnet/Haiku via the routing table in `TASKS.md`/`prompts/01-build.md`.

Prescribed services

Disclosure: some links on this page are affiliate links. We may earn a commission if you sign up through them, at no extra cost to you. We only link to services the pack actually verified against.