A lightweight library (v1.2.1) that provides an easy API for consuming Server-Sent Events (SSE) using the Fetch API, with full support for browsers and Node.js (>=18). It offers a single main function `fetchEventData` with familiar fetch-like options, including custom headers, method, body, signal, and event callbacks (onMessage, onOpen, onClose, onError). Key differentiators: no dependencies, TypeScript-first, supports POST requests and custom status handling via `skipStatusCheck`. Regular releases, actively maintained on GitHub.
npm install fetch-sseNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage of fetchEventData with POST request, Bearer token auth, and event callbacks. Includes abort signal and environment variable for URL and API key.
Set skipStatusCheck: true to handle custom status codes manually.
Use `data: JSON.stringify({...})` if you need explicit control, or pass a string as is.N/A
Use `import { fetchEventData } from 'fetch-sse'` instead of `import fetchEventData from 'fetch-sse'`.Upgrade Node.js to >=18 or install a polyfill like `fast-text-encoding`.
Add `skipStatusCheck: true` to options if you want to handle non-2xx responses in onOpen.
No dependency data recorded yet.