Skip to content

Yjs vs Traditional Databases

Yjs is a conflict-free, replicated data type, which allows for distributed, collaborative editing and offline synchronization, with automatic conflict resolution.

It can also be used as a database backend.

Recently, I was deciding between Yjs and the Prisma + tRPC + SQLite combination. As it was a small todo-style app, I settled on Yjs.

Here are the factors I considered for this decision.

YJS tRPC + Prisma + SQLite
Initial Load Fast, as client has copy of entire DB and only updates are synced Slow, as entire DB needs to be sent over. Fast, if paginated.
Concurrent edits Supported Not supported
Full-text Search Yes, client-side If paginated, server-side (requires PostgresQL). Otherwise, client-side.
Auth Supported Supported
Offline Sync Yes, with PWA No
Enforcing Relations Difficult (e.g. two users, one deletes the parent, the other deletes the child, and they sync) Yes
Enforcing Schema Client-side Server-side
Best use cases Small databases Large databases

Comments