๐—”๐—ฑ๐—ฑ ๐—Ÿ๐—ถ๐˜ƒ๐—ฒ ๐—ก๐—ผ๐˜๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐˜๐—ถ๐—ผ๐—ป๐˜€ ๐˜„๐—ถ๐˜๐—ต ๐—ฆ๐—ฆ๐—˜

Stop using WebSockets for simple notifications.

Most teams do it out of habit. You write too much code for reconnections. Server-Sent Events (SSE) work better for one-way alerts. You finish the feature in an afternoon.

SSE handles reconnections for you. The browser sends the last seen ID. The server sends missed alerts. This is free durability.

Make it production ready with these steps:

SSE is not for everything. It sends data one way. Use WebSockets for chat apps. Use SSE for alerts.

Source: https://dev.to/137foundry/how-to-add-live-notifications-to-a-web-app-with-server-sent-events-38o7