Backend and APIs · Protocol

WebSockets

A connection that stays open between a browser or app and a server so either side can send a message at any moment, which is how chat and live collaboration work.

Realtime · Free · updated

How it works

A WebSocket starts as an ordinary HTTP request that asks to 'upgrade', then becomes a two-way channel over the same connection (ws://, or wss:// when encrypted). Either side can push small messages with very little overhead, so the client no longer has to keep asking whether anything has changed. The protocol was standardised in 2011 and every modern browser supports it.

Libraries such as ws and Socket.IO (which adds rooms and automatic reconnection) run it on Node.js, and services such as Supabase Realtime, Pusher and Ably host it for you. Open connections are the hard part: a server must keep thousands of them alive, reconnect dropped clients and share messages across machines, and many serverless platforms cannot hold connections open at all.

WebSockets pros and cons

Pros

  • True two-way messaging with very little delay
  • Supported natively by every modern browser
  • Efficient for frequent small messages

Cons

  • Long-lived connections need servers that stay running
  • Reconnection, scaling across servers and auth need extra work
  • Some proxies and corporate networks interfere with them

When to use WebSockets

Pick it when

  • Chat, multiplayer games and collaborative editing
  • Both sides send messages often

Skip it when

  • Updates only flow from server to browser, where SSE is simpler
  • Updates are rare, so checking now and then is enough

WebSockets pricing

Free

Free: it is a web standard. Hosted realtime services charge by connections and messages.

Approximate, checked September 2026.What the other tools cost

WebSockets vs the alternatives

More in Backend and APIs

Realtime

All 26 Backend and APIs terms

Crafted in the dark. Shipped to the world.

Tell us what you are building. You get a private project space with a proposal and a line-by-line quote within a day.