What is eventsource-client and how does it differ from standard EventSource?
mainUnlike the standard browser EventSource API, eventsource-client is designed for modern streaming environments and provides several advanced capabilities:
- Environment Agnostic: Works in Node.js, browsers, Deno, and Bun.
- Flexible Request Methods: Supports any HTTP method (POST, PATCH, DELETE, etc.), whereas standard EventSource is limited to GET.
- Customization: Supports custom headers, request bodies, and configurable reconnection policies.
- Advanced Event Handling: Supports subscribing to any event name (even unknown ones), subscribing to
errorevents, and setting an initiallastEventId. - Modern APIs: Built on
fetch()and Web Streams.