Show HN: Hocuspocus 4 – Yjs collab server

We released Hocuspocus v4 under the MIT license a few weeks ago. It now runs on Bun, Deno and Cloudflare Workers.

For context: Hocuspocus is our open source WebSocket backend for real-time collaboration and is built on Yjs, a CRDT library (props to Kevin Jahns, the Yjs core maintainer). Hocuspocus sits on the server-side and provides real-time sync, presence/awareness, persistence, and Redis-based scaling without writing the merge logic yourself.

At Tiptap, we use it as the collaboration backend for our cloud services, but it works with any Yjs client (Slate, Quill, Monaco, ProseMirror, or your own setup), and Yjs documents aren't limited to text at all. You can sync any structured data through them.

The biggest change in v4 is that it's no longer tied to Node. The previous versions depended on the ws package, which meant you couldn't run Hocuspocus on Bun, Deno, or Cloudflare Workers. We moved to crossws, a universal websocket adapter, so that the same server now runs on Node, Bun, Deno, Cloudflare Workers, and Node with uWebSockets. That also lets you run collab at the edge, if needed.

The other changes are smaller but matter if you're using Hocuspocus in production:

1. Every core class and hook payload takes a generic Context type now, so the auth/session shape you build in onAuthenticate flows through every other hook with full type safety (defaults to any so existing code doesn't break).

2. Document updates are now processed sequentially per connection through an internal queue, which fixes a correctness bug where async hooks could cause CRDT updates to apply out of order under load.

3. Transaction origins are structured objects now with a source field instead of raw values and there's an isTransactionOrigin() helper for narrowing.

4. Hook payloads use web-standard Request and Headers instead of Node's IncomingMessage.

5. The wire protocol is backward compatible in both directions, so you can roll out servers and providers independently.

If you want to test Hocuspocus v4: npm install @hocuspocus/server @hocuspocus/provider

Docs at: https://tiptap.dev/docs/hocuspocus

Source at: https://github.com/ueberdosis/hocuspocus

Because running real-time collaboration on Workers or Durable Objects is new in v4, that's the use case we'd most like to hear your questions and feedback on.


Comments URL: https://news.ycombinator.com/item?id=48208834

Points: 4

# Comments: 1