y-protocols

Binary encoding protocols for syncing Yjs documents, broadcasting awareness/presence, and signaling authorization errors

Library
npm
v1.0.7
164 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
46 /100 Fair
Development Activity 4
Maintenance 32
Community 68
Maturity 60
Momentum 20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
73 /100 Good
Architecture 82
Code Quality 78
Innovation 75
Learning Curve 55

y-protocols implements the wire-format protocols used by Yjs network providers, giving library authors the low-level building blocks to add real-time collaboration transport to a custom backend (WebSocket server, WebRTC signaling, or otherwise) without reimplementing Yjs’s binary encoding from scratch. It’s organized into three focused modules: sync for reconciling a Yjs document’s state between two peers via a state-vector handshake (writeSyncStep1/writeSyncStep2) and update propagation, awareness for maintaining and broadcasting ephemeral per-client presence state (cursor position, username, color) with automatic timeout-based cleanup of stale clients, and auth for encoding authorization/permission errors over the wire.

Because these protocols are decoupled from any specific transport, they underpin most of the Yjs provider ecosystem (y-websocket, y-webrtc, and others), each of which just needs to move the encoded bytes across its chosen transport and call into y-protocols to interpret and apply them. This makes the package most relevant to developers building or maintaining a Yjs network provider rather than end-application developers, who typically depend on it only transitively through an existing provider package.

What You Get

  • A sync module (writeSyncStep1/writeSyncStep2/writeUpdate/readSyncMessage) implementing the state-vector handshake used to reconcile two Yjs document replicas
  • An awareness module for maintaining and broadcasting ephemeral per-client state (presence, cursor position, username/color)
  • Automatic timeout-based cleanup of awareness state for clients that stop refreshing it (default 30s)
  • An auth module for encoding authorization/permission-denied errors over the same binary wire format
  • A documented protocol spec (PROTOCOL.md) describing the exact byte-level message formats independent of the JS implementation
  • Transport-agnostic design so the same protocol logic works across WebSocket, WebRTC, or any custom transport

Common Use Cases

  • Building a custom Yjs network provider for a transport not covered by existing providers (e.g. a proprietary message bus)
  • Implementing a Yjs-compatible collaboration server that needs to speak the same sync protocol as y-websocket
  • Adding cursor/presence indicators to a collaborative editor via the awareness protocol
  • Debugging or extending an existing Yjs provider by working directly with the underlying sync/awareness wire formats

Under The Hood

Architecture - The package is split into three small, independent modules (src/sync.js, src/awareness.js, src/auth.js) each handling one protocol concern; sync.js implements the state-vector-based handshake (SyncStep1/SyncStep2) for reconciling Yjs document replicas, while awareness.js maintains a shared Map<clientID, state> with a local timeout sweep that drops clients whose state hasn’t refreshed recently. All modules build directly on lib0’s encoding/decoding primitives rather than a general-purpose serialization format, keeping the wire format compact and specific to Yjs’s needs. Tech Stack - Plain JavaScript (ES modules) with TypeScript type declarations generated via tsc --skipLibCheck from JSDoc annotations rather than hand-written .ts source; standard is used for linting and lib0 is the only meaningful runtime dependency. Code Quality - The module surface is intentionally small (under 600 lines across the three protocol files), and awareness behavior is covered by awareness.test.js; the project also maintains a separate PROTOCOL.md document specifying the exact byte-level message layout, which serves as a language-agnostic reference for reimplementing the protocol outside JavaScript. API Design - The API mirrors Yjs’s own encoder/decoder conventions (encoding.createEncoder(), decoding.createDecoder(buffer)), so developers already familiar with lib0/Yjs internals can pick it up quickly, but the protocol-level API (state vectors, sync steps, awareness timeouts) assumes real familiarity with CRDT sync mechanics rather than being a beginner-friendly high-level API.

Used by 17 apps in this directory

TypeScript
90%
MIT

open-pencil

AI Design Tools · Design Tools

9,227

An open-source design editor that reads native Figma files, ships a built-in AI assistant with 100+ design tools, and offers real-time serverless collaboration — all without giving up your files.

View details
84
Repo Health
78
Technical
69
Dependency
Built with
TypeScript 90%
Updated 6 days ago
Python
38%
Other

Open WebUI

AI Agents · AI Assistants

156,607

The extensible, privacy-first AI platform that runs Ollama, OpenAI, and any LLM backend behind a polished, feature-packed web interface.

View details
92
Repo Health
75
Technical
66
Dependency
Built with
Python 38%
Svelte 35%
JavaScript 19%
Updated 5 days ago
TypeScript
98%
Other

Outline

Collaboration · Knowledge Management

41,045

A fast, real-time collaborative knowledge base for growing teams built on React, Node.js, and ProseMirror.

View details
91
Repo Health
87
Technical
68
Dependency
Built with
TypeScript 98%
Updated 5 days ago
TypeScript
67%
AGPL 3.0

Plane

Collaboration · Productivity · Project Management

61,353

Open-source project management platform to replace Jira, Linear, and ClickUp — with built-in cycles, real-time collaborative docs, and full self-hosting.

View details
92
Repo Health
82
Technical
77
Dependency
Built with
TypeScript 67%
Python 30%
Updated 6 days ago
TypeScript
96%
Other

Refly

AI Development · Automation · No Code Platforms

7,537

Build deterministic, versioned agent skills from natural language—run them anywhere from Claude Code to Slack.

View details
68
Repo Health
76
Technical
63
Dependency
Built with
TypeScript 96%
Updated 1 weeks ago
Rust
72%
Apache 2.0

Rivet

AI Agents · Developer Tools

6,326

Stateful actors as a primitive for AI agents, real-time collaboration, and durable execution — with in-memory state, WebSockets, queues, and scheduling built in.

View details
87
Repo Health
81
Technical
64
Dependency
Built with
Rust 72%
TypeScript 25%
Updated 5 days ago
TypeScript
72%
Apache 2.0

Supabase

Authentication · Databases · Developer Tools

113,827

The open-source Postgres development platform that replaces Firebase with authentication, real-time APIs, edge functions, storage, and vector embeddings — all built on PostgreSQL.

View details
90
Repo Health
91
Technical
62
Dependency
Built with
TypeScript 72%
MDX 26%
Updated 5 days ago
Rust
33%
Other

Windmill

Automation · Developer Tools

18,257

Turn scripts into webhooks, workflows, and auto-generated UIs — the fastest self-hostable workflow engine, 13x faster than Airflow.

View details
91
Repo Health
82
Technical
64
Dependency
Built with
Rust 33%
TypeScript 24%
Svelte 22%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers