Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsMay 19, 2026·3 min de lecture

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.

Prêt pour agents

Cet actif peut être lu et installé directement par les agents

TokRepo expose une commande CLI universelle, un contrat d'installation, le metadata JSON, un plan selon l'adaptateur et le contenu raw pour aider les agents à juger l'adaptation, le risque et les prochaines actions.

Needs Confirmation · 66/100Policy : confirmer
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
Quick Use
Commande CLI universelle
npx tokrepo install fc153aa0-535b-11f1-9bc6-00163e2b0d79

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

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires