Browser compatibility
Server-sent events is supported natively by all modern browsers.
You can safely use the EventSource
interface without having to add any extra dependencies to your front-end code bundle.
Nevertheless, should you need to support older browsers or need additional features not supported by the native implementation, some polyfills are listed below.
Can I Use…
Section titled “Can I Use…”Can I use… Server-sent events
Polyfills
Section titled “Polyfills”EventSource implementation that is fully compliant with the WHATWG Server-Sent Events specification but takes more arguments.
- Usable in browser and Node.js environments (uses the Fetch API)
- TypeScript types
- Custom HTTP method
- Custom headers
- Custom retry time
- Automatic logging
A more configurable EventSource implementation that runs in browsers, NodeJS, and workers.
- Usable in browser, Node.js and worker environments (uses the Fetch API)
- TypeScript types
- Custom HTTP method
- Custom headers
- Custom URL search parameters
- Custom retry time and strategies
A flexible EventSource
replacement for JavaScript designed to consume Server-Sent Events (SSE) streams with more control and options than the standard EventSource
.
- TypeScript types
- Custom HTTP method
- Custom headers
- Control when request is initiated
Or its fork: ai-zen/node-fetch-event-source
A better API for making Event Source requests, with all the features of fetch()
- TypeScript types
- Custom HTTP method
- Custom headers
- Custom retry time and strategies
A polyfill for EventSource
.
- Custom headers
- Custom
Last-Event-ID
query parameter name
Provides a polyfill to support EventSource in browsers where it is not available.
- Custom headers
- Custom URL search parameters
- Automatic logging