Bring y-websocket to Cloudflare workers

I want to deploy y-websocket to Cloudflare workers.

Normally I would start it locally via

HOST=localhost PORT=1234 npx y-websocket

but how would I do it here? There is a documentation for it, but I honestly have no idea how to implement it such that y-websockets runs there. Hence, it would be great if you could help me here.

y-websocket is just a small node script, it should be easy to deploy.

However, y-websocket (unless you extend it), expects to be the only server that serves Yjs documents to clients.

Cloudflare workers are ephemeral. Also Cloudflare will probably spawn multiple of them in different regions to serve clients. You need some way to persist data and have the servers share state (i.e. the current state of the Yjs document). Maybe you can use Cloudflare’s persistent state for that?

It is probably easier to start with spawing a y-websocket server on a single VM instance.

Many thanks for getting back to me @dmonad .

Assume we have a very large number of quill documents that are getting edited at the same time. Is there some preferred solution to set up for such a scenario that the users can work on the quill documents collaboratively?