← Back to blog

WebSockets vs SSE: Which One Your App Needs

November 27, 2026
WebSockets vs SSE: Which One Your App Needs

If your server mostly talks and the browser mostly listens, use Server-Sent Events (SSE). If both sides send messages constantly, use WebSockets. That one question settles most cases, and the rest of this page is about the exceptions that cost founders money: proxies that break streams, reconnection nobody built, and a feature that quietly grows a second direction.

I'm Hanad, a senior software engineer in Vienna. I build first working versions of software products for founders and owner-operated businesses, so this is a decision I make early in almost every build that has live data in it. You don't need to implement either one yourself. You do need to understand the choice well enough to judge a quote, a prototype or an agency's architecture slide.

Hanad Kubat
Build the Right Live Features
For a first working version or an app rebuild, Hanad builds software with the architecture choices real users need.
Visit

Key Takeaways

  • SSE is a one-way stream from server to browser over ordinary HTTP. WebSockets are a two-way connection with its own protocol after an initial HTTP handshake.
  • Live notifications, dashboards, progress bars and AI chat answers streaming in word by word fit SSE. Chat between people, multiplayer features and collaborative editing fit WebSockets.
  • SSE reconnects by itself and resumes where it left off, if the server keeps history. With WebSockets, reconnection is code someone has to write and maintain.
  • A small two-way need (a stop button, an approval) does not force WebSockets. A normal HTTP request alongside the SSE stream usually covers it.
  • Check proxies, timeouts and authentication before launch. Most real-world failures come from there, not from the protocol.

Table of Contents

What each one actually is

Both technologies let a server push data to a browser without the browser asking every few seconds. They get there differently.

SSE is a normal HTTP response that never ends. The browser makes a request, the server answers with the content type text/event-stream and keeps writing small text blocks into it. The browser's built-in EventSource object turns each block into an event your code can react on. As HyperFetch's guide describes it, the server writes data:, event: and id: lines, the stream must be UTF-8 text, and if the client wants to send something back, it makes a normal HTTP request.

A WebSocket starts as an HTTP request with an Upgrade header. After the server agrees, the connection stops being HTTP, and both sides can send text or binary messages at any moment until one closes it. The same HyperFetch guide covers this handshake step by step.

What each one actually is

In plain terms: SSE is a radio broadcast you can answer by phone. A WebSocket is a phone call.

The differences that matter to a product owner

SSEWebSockets
DirectionServer to browser onlyBoth directions
TransportPlain HTTPOwn protocol after an HTTP upgrade
DataUTF-8 textText and binary
ReconnectionBuilt into the browserYou build it
Resuming after a dropBuilt-in Last-Event-ID mechanismYou build it
Behind proxies and CDNsBehaves like any HTTP responseNeeds upgrade support at every hop

The table follows Vercel's comparison and SchemaClient's guide. The operational point in the last row is the one that decides budgets. Because SSE is just an HTTP response that stays open, your existing login, logging and rate limiting apply to it unchanged, as SchemaClient puts it. With WebSockets, each of those needs a second look.

What an SSE event looks like

The format is small enough to read. Per the env.dev guide, a message uses up to four fields: data: for the payload, event: for a named type, id: so the browser can resume, and retry: for the reconnect delay in milliseconds. A blank line ends each message, and lines starting with a colon serve as keep-alive pings.

When the connection drops, the browser waits about three seconds by default, reconnects on its own, and sends the last id it saw in a Last-Event-ID header. That is the reconnection behavior your users get without anyone writing code for it.

When SSE is the right call

Start from traffic direction. If the server talks and the client mostly listens, SSE is simpler to build, simpler to host and simpler for the next developer to read. The typical cases:

  • AI answers streaming into a chat window. The prompt goes up as a normal POST and the tokens come back over SSE. Vercel lists this as the standard transport across AI tooling.
  • Notifications and activity feeds. The user reads; the server pushes.
  • Dashboards and monitoring screens. Live numbers flow one way.
  • Build logs and progress screens, such as an import that takes two minutes and should show how far along it is.

A well-documented real example: Shopify's engineering team chose SSE for its Black Friday live map because the map only needed data flowing from server to browser. They report 100 percent uptime over the Black Friday and Cyber Monday weekend and data reaching clients within milliseconds of being available, compared with a minimum 10-second poll in their previous system. A visualization at that scale ran on the simpler protocol.

If your product has an AI feature, my post on streaming AI interfaces covers how the streamed text shapes what users feel while they wait.

When WebSockets are the right call

Choose WebSockets when the client sends as often and as importantly as the server does. Vercel's list of fits: real-time chat, multiplayer games, collaborative document editing and active trading screens. In these, messages flow both ways many times a second, and routing every client message through separate HTTP requests becomes clumsy.

WebSockets also win when you need binary data. SSE only carries text, so binary has to be Base64-encoded, which adds roughly 33 percent overhead, according to Teleportal's transport guide. For high-volume streams of small updates, that guide also points to WebSockets.

A useful test from SchemaClient: look at how you describe the client's messages. If you keep saying "and it also sends…", SSE plus normal requests is probably enough. If the client's messages are as frequent and as important as the server's, use WebSockets.

The four-question test

When a founder asks me which to pick, I ask these in order:

  1. Does the browser need to send anything back while the stream is open? If it's rare and discrete (stop, approve, mark as read), SSE plus a plain request works. If it's constant, WebSockets.
  2. Is the data binary, or will one user hold many streams open? Either points away from SSE on older HTTP versions.
  3. Will your users sit behind corporate networks? Plain HTTP passes through company firewalls more reliably than an upgraded connection. Law firms, clinics and logistics depots often fall in this group.
  4. Who will maintain the connection logic? WebSockets leave reconnection, retries and connection state to you.

These follow the order in the Ably production guide, which I've found a sound way to frame it, adjusted here for small teams.

The two-way trap

The real risk in choosing SSE is a feature that grows. Today it's a live status page. Next quarter it needs a cancel button, then an approval step before an AI agent takes its next action. None of these requires WebSockets. The pattern is: keep the SSE stream open for server messages and send the client's commands as ordinary POST requests, with the server matching replies by request ID. Teleportal's HTTP transport guide shows this pattern in practice.

That split also gives you something useful: client writes travel over normal authenticated HTTP, so they keep request IDs, status codes, rate limits and independent retries. It's a cleaner design than pushing everything through one connection, as long as the client's side stays occasional.

Where each one breaks in production

The protocol choice rarely causes outages. The environment around it does. Here is the checklist I run before launch.

Connection limits

On HTTP/1.1, browsers allow six connections per domain, shared across all tabs. HyperFetch explains that a user with seven tabs open sees the seventh hang. Over HTTP/2, streams are multiplexed on one connection with a default limit of 100. In practice: serve SSE over HTTP/2 and this problem disappears.

Proxy buffering and idle timeouts

The most common SSE bug is a reverse proxy that holds events back instead of passing them on. The same HyperFetch guide names response buffering as the usual catch and suggests periodic comment lines as a heartbeat. The production guide on buildwithmostafa adds that idle timeouts of 30 to 60 seconds are common and that nginx's proxy buffering is the typical culprit. For WebSockets, every hop (load balancer, proxy, CDN) must support the upgrade, and sticky sessions may be needed.

Authentication

The browser's EventSource cannot set custom headers, so a bearer token in an Authorization header is not possible with it. Irurueta's documentation lists the options: a session cookie, a short-lived one-time ticket in the query string obtained from an authenticated POST (never a long-lived token, because query strings land in access logs), or fetch-based streaming that accepts any header. It also notes that a tab outliving its session gets a 401 on reconnect, which ends the stream permanently until a new one is created. Plan for that screen: "your session expired, sign in again."

WebSockets have the same header limitation in the browser. Encore's guide points out that the WebSocket constructor can't set an Authorization header either, so authentication has to happen during the handshake in another way.

Reconnection and missed messages

SSE gives you the reconnect and the Last-Event-ID header. It does not give you the history. The server must keep recent events and replay what the client missed, and when the requested position is too old, it should tell the client to reload the full state rather than silently skip the gap. This is the detail that separates a demo from a product. With WebSockets, per SchemaClient, reconnection is "your code, your backoff strategy, and your bug."

Are WebSockets deprecated?

No. WebSockets remain the right tool for genuinely two-way, high-frequency features, and nothing about SSE retires them. What has changed is the default. Guidance has moved toward starting with SSE unless you specifically need bidirectional communication, largely because HTTP/2 removed the connection cap and because AI providers adopted SSE for streaming responses. Choose by traffic direction, not by fashion.

What this means for a prototype from Lovable, Bolt or Bubble

Prototype builders often wire live updates with polling, where the page asks the server every few seconds, or with a platform feature you can't inspect. That works for ten users and the demo. It starts to hurt when real users arrive: the bill grows, updates lag, and nobody can explain how it works.

When I rebuild such a product as real code, live data is usually one of the first things I replace. For most founder products, a progress screen, a notification list, an AI answer that streams in, that means SSE over HTTP/2 with plain requests for the occasional action. It stays inside a boring, widely known stack, so the next developer can read it. If your product truly is a chat tool or a shared editor, I'd design for WebSockets from day one, and I'd tell you that before you spend anything.

If you're deciding how this fits your wider architecture, my web stack decision guide lays out the surrounding choices.

Build it once, build it readable

I build the first real version of a product as a fixed-price, fixed-scope project, finished in two to four weeks, and you own the code from the first commit. Builds start from €12,000 (see what I build), and the price is possible because there is no agency overhead, no project-manager layer and no offshore markup. You speak directly with the senior engineer who writes the code, and you see working progress before you pay. Live updates, payments and logins that work belong in that first version, not in a later rewrite.

Perspective

The most expensive real-time mistake I see is not picking the wrong protocol. It's picking a complicated one for a feature that didn't need it, then leaving nobody able to maintain it.

Founders usually describe the need as "real time," and that phrase hides two very different things. Sometimes it means a screen that updates itself. Sometimes it means two people typing to each other. The first is a one-way stream and is cheap to build and cheap to hand over. The second is a different class of system, and it deserves its own budget and its own design.

My rule is to start with the simpler transport, keep client actions as ordinary requests, and write the event history down properly so a dropped connection recovers cleanly. That is deliberate: a plain, well-known approach is easier for the next developer to pick up, and handing over code that someone else can read is part of the job.

If a WebSocket is the honest answer for your product, I'll build it that way. If an off-the-shelf tool does the job, I'll say that too.

Hanad Kubat

FAQ

What is better than WebSockets?

It depends on the direction of your data. For one-way updates such as notifications, dashboards and streamed AI answers, SSE is usually simpler. For rare updates every 30 seconds or more, plain polling can be the easiest option to cache and debug, per websocket.org's chooser. For two-way, high-frequency features, WebSockets stay the right choice.

Does SSE use WebSockets?

No. SSE is a regular HTTP response that stays open and carries text/event-stream content. A WebSocket upgrades an HTTP request into a separate protocol. They solve overlapping problems but share no machinery, which is why SSE passes through ordinary proxies and CDNs more easily.

Can SSE do two-way communication?

Not on its own: the stream only flows from server to browser. The usual pattern is to send the client's messages as normal HTTP POST requests while the SSE stream carries the server's messages. That covers features like stop buttons and approvals without a WebSocket.

What happens when an SSE connection drops?

The browser reconnects automatically after about three seconds, or after the delay the server set with retry:, and sends the last event ID it received in a Last-Event-ID header. The server then needs to replay what was missed from stored history. If the ID is too old, it should tell the client to reload the full state.

Hanad Kubat
Discuss Your App’s Live Data
Email Hanad about your app’s real-time needs and the first working version or rebuild that could fit your product.

Sources