What is the right way to use y-websocket on the server

I have searched everywhere and only saw the server setup from the demo repository.
Even reading the docs wasn’t of much help and the method stated there to run the server was using npx.
How do I setup y-websocket on the server that should run my own file rather than using npx?

This is what I’ve been able to come up with so far from the demo server

wss.on(‘connection’, (conn, req) => {
let options = { gc: true }
setupWSConnection(conn, req, options)
})

I want to persist the document(s) to MongoDB and also add some checks etc, but I couldn’t find a way to access a particular Y doc.

You could also have a look at hocuspocus or y-sweet. They have a more accessible documentation.

1 Like