← Back to writing
Field Note№ 017 · Field notes from the studio

A thirty-line CRDT

FIELD NOTE№ 017Studio D&M02 Jan 2026⟳

You probably don't need a CRDT library. For a surprising number of sync problems, a last-writer-wins register and a clock will do.

CRDTs have a reputation for being academic and heavy. For collaborative text, fair enough. But a lot of “sync” problems are really just per-field last-writer-wins, and that fits in about thirty lines.

sync/lww.ts
function merge(a, b) {
  return a.ts >= b.ts ? a : b  // last writer wins
}

Pair that with a hybrid logical clock so timestamps survive clock skew, and you have offline-first sync for structured data without a single dependency. We shipped exactly this in Field Notebook and never reached for more.

The lesson isn't “avoid libraries.” It's: understand the shape of your conflict before you import someone else's solution to a harder one.

MMarcus Okafor · Studio D&MEnd of note
Keep reading
← Newer note№ 018

Why we left the monorepo

Essay · 12 min
Older note →№ 016

Lumen Type, front to back

Case Study · 18 min