y-protocols

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

Library
npm
v1.0.7
161stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
49/100Fair
Development Activity16
Maintenance32
Community68
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
73/100Good
Architecture82
Code Quality78
Innovation75
Learning Curve55

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 16 apps in this directory

TypeScript
88%
Other

AFFiNE

Productivity · Project Management · Note Taking

71,668

Write, draw, and plan in one infinite canvas — the open-source alternative to Notion and Miro that keeps your data yours.

View details
91
Repo Health
87
Technical
68
Dependency
Built with
TypeScript88%
Updated today
TypeScript
72%
AGPL 3.0

APITable

Low Code Platforms · Databases

15,526

API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.

View details
53
Repo Health
77
Technical
60
Dependency
Built with
TypeScript72%
Java22%
Updated 9 months ago
TypeScript
99%
AGPL 3.0

Cherry Studio

AI Assistants

50,753

All-in-one AI desktop client with 300+ assistants and multi-model support

View details
88
Repo Health
84
Technical
71
Dependency
Built with
TypeScript99%
Updated today
Python
51%
MIT

Docs

File Storage · CMS

16,733

Open-source collaborative knowledge platform with real-time editing, AI writing tools, and full self-hosting control — built by the French and German governments.

View details
87
Repo Health
81
Technical
72
Dependency
Built with
Python51%
TypeScript42%
Updated 2 days ago
Java
34%
Apache 2.0

Enso

Analytics · Data Engineering · Low Code Platforms

7,437

A visual and textual programming platform for data prep and analysis where the node graph and the underlying Enso code are always perfectly in sync, built by an Alteryx co-founder on a GraalVM engine.

View details
70
Repo Health
90
Technical
62
Dependency
Built with
Java34%
TypeScript27%
Scala26%
Updated 1 weeks ago
TypeScript
72%
Other

Epicenter

Knowledge Management · Note Taking · Developer Tools

4,761

A local-first monorepo led by Whispering, an open-source speech-to-text app, built on an MIT toolkit that turns your data into plain Markdown and SQLite files you own instead of a database you rent.

View details
88
Repo Health
90
Technical
68
Dependency
Built with
TypeScript72%
Svelte15%
Updated today
TypeScript
61%
EPL-2.0

Huly Platform

Project Management · Team Chat · Collaboration

27,384

Open-source all-in-one workspace that replaces Linear, Jira, Slack, and Notion for product and engineering teams.

View details
90
Repo Health
86
Technical
64
Dependency
Built with
TypeScript61%
Svelte34%
Updated 1 weeks ago
TypeScript
92%
Other

n8n

Automation · No Code Platforms

201,152

Code when you need it, UI when you don't — the workflow automation platform built for technical teams who refuse to choose.

View details
95
Repo Health
87
Technical
66
Dependency
Built with
TypeScript92%
Updated today
TypeScript
89%
MIT

open-pencil

AI Design Tools · Design Tools

7,864

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
80
Repo Health
78
Technical
70
Dependency
Built with
TypeScript89%
Updated today

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

Search