This is a standalone Cloudflare Worker for the y-webrtc signaling step used by Write's peer-to-peer collaboration. It is intentionally isolated from the main app package and can be deployed independently with Wrangler.
- Accepts WebSocket upgrades
- Implements the small
y-webrtcpub/sub signaling protocol (subscribe,unsubscribe,publish,ping) - Uses a Durable Object as the broker so all signaling clients share a single room registry
This worker only handles peer discovery and signal fanout. It does not carry document state; the actual sync remains peer-to-peer over WebRTC.
cd signaling
npm install
npm run devWrangler will print a local WebSocket URL you can use as the signaling endpoint (set it as VITE_SIGNALING_URL in ../app/.env.local).
cd signaling
pnpm install
pnpm run deployAfter deploy, Cloudflare will give you a Worker URL such as:
wss://subscript-write-signaling.<your-account>.workers.devUse that URL as VITE_SIGNALING_URL when building the app.
No. By default VITE_SIGNALING_URL points at the public wss://y-webrtc-eu.fly.dev relay, so Write works out of the box without deploying anything.
Write is local-first: your script never leaves your browser except peer-to-peer over WebRTC. This worker (or the public relay) only helps two browsers find each other; it never sees document content. If you'd rather not depend on a third-party relay, deploy your own copy with the steps above and point VITE_SIGNALING_URL at it.