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, some polyfills are listed below.
Can I Use…
Can I use… Server-sent events
Polyfills
lukas-reining/eventsource
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
joshmossas/event-source-plus
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
mpetazzoni/sse.js
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
Azure/fetch-event-source
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
Yaffle/EventSource
A polyfill for EventSource
.
- Custom headers
- Custom
Last-Event-ID
query parameter name
amvtek/EventSource
Provides a polyfill to support EventSource in browsers where it is not available.
- Custom headers
- Custom URL search parameters
- Automatic logging