SkillsMay 19, 2026·3 min read

Yjs — High-Performance CRDT Framework for Real-Time Collaboration

A modular CRDT implementation that enables real-time collaborative editing in any application, with network-agnostic sync providers for WebSocket, WebRTC, and more.

Agent ready

Review-first install path

This asset needs a review step. The copied prompt tells the agent to dry-run, show the writes, then proceed only after confirmation.

Needs Confirmation · 66/100Policy: confirm
Agent surface
Any MCP/CLI agent
Kind
Skill
Install
Single
Trust
Trust: Established
Entrypoint
Quick Use
Review-first command
npx -y tokrepo@latest install fc153aa0-535b-11f1-9bc6-00163e2b0d79 --target codex

Dry-run first, confirm the writes, then run this command.

Introduction

Yjs is a high-performance CRDT (Conflict-free Replicated Data Type) framework written in JavaScript. It allows multiple users to edit the same data concurrently without conflicts. Yjs is editor-agnostic and works with Tiptap, ProseMirror, Monaco, CodeMirror, Quill, and many other editors.

What Yjs Does

  • Merges concurrent edits automatically without a central server
  • Provides shared data types: Text, Array, Map, and XML Fragment
  • Syncs state over WebSocket, WebRTC, or any custom transport
  • Supports offline editing with automatic reconciliation on reconnect
  • Tracks awareness (cursor positions, user presence) across peers

Architecture Overview

Yjs represents shared state as a document (Y.Doc) containing typed structures. Each edit is encoded as an update operation that can be applied in any order. The CRDT algorithm ensures all peers converge to the same state regardless of message ordering. Providers handle transport: y-websocket for client-server, y-webrtc for peer-to-peer, and y-indexeddb for local persistence.

Self-Hosting & Configuration

  • Install yjs and a provider (y-websocket, y-webrtc, or y-indexeddb)
  • Run the y-websocket server: HOST=localhost PORT=1234 npx y-websocket
  • Bind shared types to your editor using bindings (e.g., y-prosemirror, y-monaco)
  • Persist documents server-side with LevelDB or a custom storage adapter
  • Scale horizontally by partitioning documents across WebSocket server instances

Key Features

  • Sub-millisecond merge performance even with large documents
  • Works offline-first with sync on reconnect
  • Awareness protocol for live cursors and user presence
  • Undo/redo manager with per-user scope
  • Sub-document support for lazy loading parts of a large document

Comparison with Similar Tools

  • Automerge — Rust-based CRDT, better for structured data; Yjs is faster for text
  • ShareDB — OT-based, requires a central server; Yjs is decentralized
  • Liveblocks — managed service with CRDT under the hood; Yjs is self-hostable
  • Fluid Framework — Microsoft-backed, more opinionated architecture
  • Gun.js — decentralized database with eventual consistency, different use case

FAQ

Q: Which editors does Yjs support? A: Tiptap, ProseMirror, CodeMirror, Monaco, Quill, Slate, Lexical, and others via official or community bindings.

Q: Can Yjs work without a server? A: Yes, use y-webrtc for peer-to-peer sync or y-indexeddb for local-only persistence.

Q: How does conflict resolution work? A: Yjs uses CRDTs, so all concurrent edits are merged deterministically. No conflicts require manual resolution.

Q: How large can documents get? A: Yjs handles documents with millions of operations efficiently through incremental encoding and garbage collection.

Sources

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets