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: 155Edge
12–18Not supported
79+Supportedsince Jan 15, 2020
Current: 154Firefox
1–5Not supported
6+Supportedsince Aug 16, 2011
Current: 157Safari
1–4Not supported
5+Supportedsince Jun 7, 2010
Current: 27MobileChrome Android
18+Supportedsince Jun 27, 2012
Current: 155Firefox Android
4–44Not supported
45+Supportedsince Mar 8, 2016
Current: 157Safari iOS
1–4.2Not supported
5+Supportedsince Oct 12, 2011
Current: 27How 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
}Documentation (MDN)
Specification
Usage share
Sub-features
Support for each part of the feature (11). The overall table above shows when the whole feature works.
| Sub-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| EventSource | 6 | 79 | 6 | 5 | 18 | 45 | 5 |
| EventSource.EventSource | 6 | 79 | 6 | 5 | 18 | 45 | 5 |
| EventSource.EventSource.options_withCredentials_parameter | 26 | 79 | 11 | 7 | 26 | 45 | 7 |
| EventSource.close | 6 | 79 | 6 | 5 | 18 | 45 | 5 |
| EventSource.error_event | 6 | 79 | 6 | 5 | 18 | 45 | 5 |
| EventSource.message_event | 6 | 79 | 6 | 5 | 18 | 45 | 5 |
| EventSource.open_event | 6 | 79 | 6 | 5 | 18 | 45 | 5 |
| EventSource.readyState | 6 | 79 | 6 | 5 | 18 | 45 | 5 |
| EventSource.url | 18 | 79 | 6 | 6 | 18 | 45 | 6 |
| EventSource.withCredentials | 26 | 79 | 6 | 7 | 26 | 45 | 7 |
| EventSource.worker_support | 6 | 79 | 133 | 5 | 18 | 133 | 5 |