Y-S2 is a Cloudflare Worker that provides real-time collaborative document editing using Yjs with S2 as the distribution channel and an R2 bucket as the storage provider. It provides scalable WebSocket-based document synchronization where document updates are made durable on an S2 stream and distributed to connected clients and reactively persisted to the R2 bucket.Documentation Index
Fetch the complete documentation index at: https://s2.dev/docs/llms.txt
Use this file to discover all available pages before exploring further.
Getting Started
Prerequisites
- Cloudflare account with Workers enabled
- S2.dev account with a basin that has
Create stream on append/readenabled - Scoped access token to your S2 basin
- R2 bucket for snapshot storage
Environment Variables
Deployment
Client Integration
Connect to the deployed worker using the Yjs WebSocket provider:How It Works
- Document Updates: When users make changes to a Yjs document, updates are sent to the Y-S2 worker via WebSocket
- S2: Updates are appended to an S2 stream for durability and real-time distribution
- Client Distribution: Connected clients receive updates in real-time through WebSocket connections
- R2 Persistence: Document snapshots are periodically saved to R2 bucket storage for efficient loading

