I'm a computer science student building a side project with a Node/Express backend and React frontend. The app will display a live transit map with tram arrival data pushed from the server to the browser. The client doesn't need to send real-time messages back; it may only make ordinary requests for things like filters or configuration. Most tutorials recommend Socket.io or WebSockets, but Server-Sent Events seem simpler because they use a standard HTTP connection. Is SSE the better choice for a one-way stream like this, and what important disadvantages should I consider? Why are WebSockets so often treated as the default?
3 Answers
The main practical caveat is connection limits. With HTTP/1.1, browsers commonly allow only around six simultaneous connections per domain, and each open SSE stream uses one. That can become annoying if someone opens several tabs. HTTP/2 multiplexes streams and largely avoids this issue, so verify that production is actually serving HTTP/2. For one map stream, though, this probably won't be a problem.
SSE is a very good fit here. It is designed for a persistent server-to-browser stream and works well for live dashboards, notifications, status pages, and transit updates. In the browser you can use EventSource, send JSON events, and let the client reconnect automatically. WebSockets are more appropriate when the client also needs to send frequent real-time messages, such as in chat, multiplayer games, or collaborative editing.
Make sure the SSE endpoint sends heartbeats and that your server handles reconnects sensibly. Including event IDs lets the client send Last-Event-ID after a disconnect, so the server can resume or catch it up. Also check reverse-proxy buffering and idle timeouts, since those can prevent events from arriving immediately even when the application code is correct.

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically