Comparison
How Twinstate relates to other sync engines and data tools, and when another one is the better choice. Comparisons are as of 2026-10 and say what each tool is built for, not which is better.
Where the server is the application
Twinstate is for apps in which the server is the application: it runs the logic (agents, jobs, streaming replies, workflows), and the data lives in whatever storage suits it. Engines that replicate a database are for apps in which the database is the application: Postgres holds the truth, many services write to it, and clients query it.
| the server is the application | the database is the application | |
|---|---|---|
| examples | assistants and agents, job-heavy tools, per-user or per-workspace apps | Postgres-centred CRUD with many writers |
| fits | Twinstate | Zero, ElectricSQL, PowerSync |
Two families of sync engine
| A: the database orders writes | B: a server per unit orders writes | |
|---|---|---|
| how | writes go through your API into the database; a sync service reads the database's change log and streams it to clients | a stateful server holds the state, runs the logic and orders every write; many units run side by side |
| needs | a database with a durable, ordered, resumable change log (Postgres logical replication, MongoDB change streams, MySQL's binlog), one source per sync service | nothing: the server's own queue is the log, so storage may be anything, mixed per kind |
| scales by | adding sync nodes for reads; writes scale with the database | partitions across machines; one unit's writes go through one queue |
| who | ElectricSQL, Zero, PowerSync, Supabase Realtime | Twinstate, Durable Objects, PartyKit, Liveblocks, tldraw sync, Figma's per-file servers |
A database hook that is not a durable log (SQLite's update_hook, which sees only its own connection's writes and is lost on a crash) cannot feed family A. Several databases can be streamed together (Debezium into Kafka), but nothing then orders a write in one against a write in another.
Twinstate, Zero and PowerSync
| Twinstate | Zero / PowerSync | |
|---|---|---|
| server logic | first-class: turns, jobs as state, appendable text streamed from memory | custom mutators or your API; streamed text is a database write per token |
| storage | any, through one adapter per kind | one source database (Postgres first) |
| infrastructure | a library in your process | a sync service beside your database |
| access | policies on every field and record, projected per viewer (sessions and access) | server-defined queries and mutators (Zero), sync rules (PowerSync) |
| offline writes | a durable outbox: idempotent, held after 24 hours, never drops typed text | PowerSync: an upload queue; Zero: writes need a connection |
| enforced by types | almost every mistake does not compile | typed APIs, fewer enforced rules |
| apps with many writers to Postgres | bridges: the change log into mutate | no glue: every write reaches clients |
| queries on the client | declared shapes and windows | relational queries over synced data (Zero, as named queries), SQLite on the device (PowerSync) |
| large datasets on the device | the cache is a starting point | built for it |
| native mobile | web and React | PowerSync: Flutter, Kotlin, Swift |
| maturity | early | in production, hosted options |
Neighbours in family B
| what it is | a unit | data | offline writes | hosting | |
|---|---|---|---|---|---|
| Durable Objects | a primitive: a single-threaded actor with storage | an object | yours to build | yours to build | Cloudflare |
| PartyKit | rooms on Durable Objects | a room | yours (often Yjs) | yours to build | Cloudflare |
| Liveblocks | hosted rooms: storage, presence, comments | a room (one document) | CRDT structures | a CRDT merges later | managed |
| tldraw sync | sync for tldraw documents | a document | tldraw's records | held while disconnected | self-hosted (a Durable Objects template) |
| Yjs servers (Y-Sweet, Hocuspocus) | servers for Yjs documents | a document | CRDTs | a CRDT merges | self-hosted or managed |
| Twinstate | a framework in your server | a server (a partition) holding many kinds, loaded lazily | typed records, last write wins per field | a durable outbox | anywhere Node runs |
Twinstate is what one would otherwise build inside a Durable Object, and it holds an app's whole model per unit, not one document. Where it is weaker: two people typing in the same paragraph (a CRDT's job: pair Twinstate with a Yjs server for those fields, or a merging field encoding later), presence and cursors (not built in), and hosting (none managed).
Running on many servers
All of these run on many servers; what differs is what can be spread out. Durable Objects, Liveblocks and Twinstate spread units (objects, rooms, partitions), each on one server at a time, so one very busy unit is bounded by one machine. Only CRDT servers keep one document on several servers, each taking writes and ordering them itself, because their copies merge in any order. Engines built on a database take writes on many servers too, but the database orders them, so the database's primary is the one place each document's writes meet. What orders the writes decides what running on many machines takes:
| what orders writes | routing | one owner per unit | a deploy, for clients | what you run | |
|---|---|---|---|---|---|
| Twinstate | a queue per partition | hashed by partition at the load balancer | a lock per partition, fencing in the store | reset (a new epoch), from the store | Node pods, a lock store, your data store (scalability) |
| Durable Objects, PartyKit | the object | the platform | the platform | the platform restarts objects from their storage | nothing: Cloudflare runs it |
| Liveblocks | its servers, per room | managed | managed | managed | nothing: a service |
| Yjs servers | nobody: CRDTs merge | sticky helps, not required | not needed: copies merge (via Redis) | reconnect and merge | instances, and Redis for several |
| Zero | Postgres | a load balancer | a single replication manager; view-syncers interchangeable | a client's record, kept in Postgres, lets a syncer resume it | Postgres and zero-cache |
| ElectricSQL | Postgres, through your API | plain HTTP, cacheable | not needed for reads | resumes by its offset | Postgres and Electric |
| PowerSync | your database, through your API | a load balancer | the database | resumes by checkpoint | your database and the PowerSync service |
| Orleans, Akka Sharding | the actor | the framework's directory | the framework (leases, a coordinator) | actors reactivate elsewhere | a cluster of their runtime |
Any engine with one writer per unit needs routing by unit and one owner at a time, from a platform (Durable Objects, Liveblocks), a framework (Orleans, Akka), or your infrastructure (Twinstate keeps only close and the server's outbox interface). The ones that need neither give up single-writer ordering: to a database (Zero, ElectricSQL, PowerSync) or to CRDTs.
Twinstate or Durable Objects
They sit at different layers. Durable Objects are a platform primitive (hosting, a single-threaded actor, storage, routing); Twinstate is a sync framework (the data model, the client replica, optimistic effects, the outbox, lazy loading, policies, React, generated tests), and could run on Durable Objects, a partition per object (on the roadmap). Building that sync layer on Durable Objects yourself is most of what Twinstate is; Cloudflare's Agents SDK covers a thin slice of it (state on an agent, synced with a hook).
| choose | when |
|---|---|
| Durable Objects alone | a small realtime feature (a counter, a room, presence) on Cloudflare, with sync logic you are glad to write |
| Twinstate on Node | an app's state on many devices, with server work that needs a full runtime (subprocesses, long connections, any npm package), your own data and infrastructure, no platform lock-in |
| Twinstate on Durable Objects (later) | both: the framework's guarantees and no servers to run, for apps that fit within Workers' limits |
TanStack
TanStack's libraries are headless building blocks; Twinstate is an opinionated framework, strict where strictness buys a guarantee.
| TanStack Query | TanStack DB | Twinstate | |
|---|---|---|---|
| covers | the client cache | the client store and live queries | server engine, protocol, client and React |
| data from | your API (pull) | any collection you plug in (Query, Electric, PowerSync, RxDB) | its own server (push) |
| ordering and confirmation | none | the backend's | one queue; replies after data |
| client queries | per request | live joins and filters | declared shapes and windows |
They combine rather than compete:
- TanStack Query keeps one-off REST calls; Twinstate holds live, shared state. Both live in one app.
- TanStack Router (and React Router):
client.preload(Entry, props)in a route loader starts a screen's data with its code. - TanStack DB could take Twinstate as a collection, giving live client queries over the replica (on the roadmap).
What is strict, and why
Strict at the core, composable at the edges. The core is strict because each rule buys a guarantee: one queue (ordering, no conflicts), a durable outbox (no lost work), policies on every field (nothing visible by accident), compile-time rules (mistakes caught before they ship). The edges stay open, so Twinstate can be adopted next to what an app already has: Query beside it, any router, bridges into an existing backend (server.mutate(…, { key }), designed), and a framework-free client API that other bindings can build on.
Three examples
| app | Twinstate's role | partitions | the truth |
|---|---|---|---|
| a personal assistant | the backend | one per user | its files or database, through adapters |
| banking | the live view of a ledger | one per user | a ledger database; transfers are intents, results bridged back into both users' partitions |
| a social network | the realtime layer over a sharded backend | a home per user; one per thread or community | sharded stores, a timeline store fed by fan-out, search and counters elsewhere |
The database layouts and data flows for each are in scalability.