What is a WebSocket?

Corbin Brown
2 min read
WebSockets Explained in 4 Minutes (for beginners)Premieres soonPart of the Vibe Coding Fundamentals video series on YouTube.
Normal web traffic works like sending letters: the browser mails a request, the server mails back a response, and the conversation is over — every update requires another letter. A WebSocket replaces the mail with a phone call. Browser and server open a line once and keep it open, and after that either side can speak at any moment. That standing line is what makes things feel live: chat messages appearing without a refresh, teammates' cursors gliding around a document, an AI response streaming in word by word.
Letters vs. the open line
The old workaround was polling — the browser mailing “anything new?” every few seconds forever. It works, wastefully, like checking your mailbox every thirty seconds for a letter that arrives once a day. A WebSocket inverts it: nobody asks, the server just says the new thing the moment it exists. Less waste, and crucially, no delay between something happening and you seeing it.
Does your app need one?
The test is one question: do users need to see things change without acting? Chat, live notifications, collaborative editing, multiplayer anything, live dashboards — yes. Forms, checkout, blogs, dashboards refreshed on click — no, and adding WebSockets there is complexity without payoff. Keeping thousands of phone lines open is genuinely harder for servers than answering letters, which is why most builders reach for a managed service (Pusher, Ably, Supabase Realtime) instead of running their own switchboard. Your agent can wire any of them — the cost question is worth asking first.
FAQ
Is ChatGPT's streaming a WebSocket?
Same family, different member — most AI streaming uses server-sent events, a one-way version where only the server talks. The mental model is identical: an open line instead of repeated letters. Your agent picks the right one; the concept transfers.
Why does my realtime feature disconnect?
Open lines drop — laptops sleep, WiFi blips, phones change towers. Production realtime code always includes automatic reconnection, and any decent library or service handles it. If an agent hand-rolled your WebSocket code, ask whether reconnection is covered.