Menu
Back to Discussions

So, which is better for building real-time updates in a collaborative document editor: WebSockets or Server-Sent Events?

Wei Chen
Wei Chen
·5979 views
Hey everyone. I'm building a document editor, kind of like Google Docs, and I need to figure out the best way to handle real-time updates. The big thing is making sure everyone sees changes right away. I'm thinking WebSockets for two-way communication, but some people say Server-Sent Events (SSE) could work for easier stuff. But for our editor, lots of people will be typing at once, and we'll have to send things like diffs. I'm a little worried about WebSockets and how to keep track of state, plus what happens if someone reconnects. SSE is simpler for the server to just send updates, but then I'd still need another way for the client to send stuff back to the server. Has anyone made something like this before? What did you learn? Is the extra work with WebSockets worth it because it handles both directions so easily for this kind of app, or am I making SSE seem more complicated than it is by needing a seperate API for writing from the client?
29 comments

Comments

Loading comments...