coderef

Server-sent eventsBaseline · Widely available

The EventSource API creates a connection to a server and listens to a stream of events sent by the server.

Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Jan 15, 2020. Widely available since Jul 15, 2022.

Browser support

DesktopChrome
1–5Not supported
6+Supportedsince Sep 2, 2010
Current: 155
Edge
12–18Not supported
79+Supportedsince Jan 15, 2020
Current: 154
Firefox
1–5Not supported
6+Supportedsince Aug 16, 2011
Current: 157
Safari
1–4Not supported
5+Supportedsince Jun 7, 2010
Current: 27
MobileChrome Android
18+Supportedsince Jun 27, 2012
Current: 155
Firefox Android
4–44Not supported
45+Supportedsince Mar 8, 2016
Current: 157
Safari iOS
1–4.2Not supported
5+Supportedsince Oct 12, 2011
Current: 27

How to use

This feature is Baseline widely available — use it freely, no fallback needed.

Example

Full syntax and examples are on MDN: EventSource.

Feature detection

JS · check before using
if ("EventSource" in globalThis) {
  // EventSource is available
} else {
  // load a polyfill or use a fallback
}

Sub-features

Support for each part of the feature (11). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
EventSource6796518455
EventSource.EventSource6796518455
EventSource.EventSource.options_withCredentials_parameter267911726457
EventSource.close6796518455
EventSource.error_event6796518455
EventSource.message_event6796518455
EventSource.open_event6796518455
EventSource.readyState6796518455
EventSource.url18796618456
EventSource.withCredentials26796726457
EventSource.worker_support6791335181335