yjs-sync

Synchronize Yjs CRDT documents via Durable Streams with SSE or long-polling.

1.7k|64|Updated Dec 4, 2025
One-click install
npx skills add https://github.com/durable-streams/durable-streams --skill yjs-sync
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: yjs-sync
Source: https://github.com/durable-streams/durable-streams/tree/main/packages/y-durable-streams/skills/yjs-sync
Command: npx skills add https://github.com/durable-streams/durable-streams --skill yjs-sync

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Developers need a reliable way to synchronize Yjs CRDT documents over network connections while handling authentication, connection lifecycles, and error recovery. Without a dedicated provider, implementing these concerns manually leads to duplicated code, fragile reconnection logic, and inconsistent state across clients.

Core Features & Use Cases

  • Configurable Provider Options: Set document, base URL, doc ID, optional awareness, custom headers, live mode (SSE or long‑poll), and auto‑connect behavior.
  • Dynamic Authentication: Supply static tokens or functions that refresh per request, enabling seamless credential rotation.
  • Robust Connection State Machine: Automatic transitions between disconnected, connecting, and connected states with graceful handling of errors.
  • Error Recovery & Reconnection: Built‑in retries for network hiccups, server errors, and snapshot discovery failures, while emitting clear status events.
  • Event‑Driven API: Listen to synced, status, and error events to integrate with UI frameworks such as React.

Quick Start

Ask the assistant to configure a YjsProvider for document “my-doc” using SSE mode with automatic reconnection.

Frequently Asked Questions about yjs-sync

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I sync Yjs CRDT documents across clients in real time?

You can sync Yjs CRDT documents across clients in real time using a provider that manages SSE or long-poll streaming, authentication headers, and automatic reconnection over durable streams to ensure consistent collaborative editing states.

What is the best way to handle authentication for Yjs collaborative editing streams?

Handling authentication for Yjs collaborative editing streams is done by supplying static tokens or dynamic functions that refresh per request, enabling seamless credential rotation while generating custom headers for each streaming connection.

Can I use SSE and long-polling for Yjs real-time synchronization on mobile applications?

Yes, you can use SSE and long-polling for Yjs real-time synchronization on mobile applications, as the provider supports both live streaming modes to accommodate different network environments and platform constraints.

How does the connection state machine handle Yjs network errors and reconnections?

The connection state machine handles Yjs network errors and reconnections through automatic transitions between disconnected, connecting, and connected states, providing built-in retries for server errors and snapshot discovery failures while emitting clear status events.

Do I need a custom provider to manage Yjs document lifecycle and error recovery?

You need a custom provider to manage Yjs document lifecycle and error recovery because manually implementing connection state machines, retries, and snapshot discovery leads to duplicated code, fragile reconnection logic, and inconsistent client states.

How do I integrate Yjs sync status events with UI frameworks like React?

You integrate Yjs sync status events with UI frameworks like React by using the event-driven API to listen for synced, status, and error events, allowing your components to react dynamically to real-time connection lifecycle changes.