@microsoft/fetch-event-source

A fetch()-powered client for Server-Sent Events that supports headers, request bodies, and retries

Library
npm
v2.0.1
2,890 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
44 /100 Fair
Development Activity 0
Maintenance 20
Community 56
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
70 /100 Good
Architecture 70
Code Quality 66
Innovation 65
Learning Curve 78

@microsoft/fetch-event-source replaces the browser’s built-in EventSource with an implementation built on fetch(), removing that API’s restriction to GET requests with no custom headers or body. It streams and parses Server-Sent Events (SSE) the same way EventSource does, but lets callers set arbitrary headers (for auth tokens), send a POST body, control retry/backoff behavior, and cleanly cancel an in-flight stream via AbortController.

What You Get

  • An fetchEventSource() function with the same event callbacks as native EventSource (onopen, onmessage, onclose, onerror) plus full control over method, headers, and body
  • Automatic reconnect-with-backoff on connection drops, matching the SSE spec’s retry semantics, with a hook to override or disable it
  • First-class AbortController/signal support so a caller can cancel a stream cleanly instead of leaking an open connection
  • A standards-compliant SSE parser (parse.ts) that handles multi-line data fields, comments, and the retry:/id: control fields per spec

Common Use Cases

  • Streaming token-by-token completions from an LLM API (OpenAI, Azure OpenAI) that requires a POST body and bearer-token header
  • Building a live-updating dashboard or notification feed that needs SSE but must attach an auth header the native EventSource can’t send
  • Replacing polling with a long-lived streamed connection for progress updates on a long-running server-side job
  • Any browser client that needs SSE semantics with the flexibility of fetch() — custom retry logic, request cancellation, or non-GET methods

Under The Hood

Architecture The library is deliberately small: fetch.ts (154 lines) wraps the browser’s native fetch() call, wires it to an AbortController, and manages the retry/backoff loop and event-callback dispatch, while parse.ts (183 lines) implements a dedicated line-based SSE parser that incrementally consumes the streamed response body and emits parsed {event, data, id, retry} messages. index.ts simply re-exports the public fetchEventSource function. Tech Stack Pure TypeScript with zero runtime dependencies, compiled to both CJS (lib/cjs) and ESM (lib/esm) output via two separate tsconfig targets, keeping the published bundle framework-agnostic and usable in any environment with a fetch and ReadableStream implementation. Code Quality The parser has a dedicated Jasmine spec file (parse.spec.ts, 353 lines) exercising SSE parsing edge cases (multi-line fields, comments, partial chunks) in detail, though the higher-level fetch.ts reconnect/backoff logic itself has no equivalent test coverage — test depth is concentrated on the parsing layer, the part most prone to subtle spec-compliance bugs. API Design The API is intentionally a drop-in shape match for the native EventSource callbacks (onopen/onmessage/onerror/onclose), so migrating existing SSE consumer code mostly means swapping the import and adding a fetch-style options object (method, headers, body, signal) — there’s no new mental model to learn, just an extended options surface.

Used by 9 apps in this directory

TypeScript
72%
AGPL 3.0

APITable

Databases · Low Code Platforms

15,647

API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.

View details
68
Repo Health
77
Technical
60
Dependency
Built with
TypeScript 72%
Java 22%
Updated 1 months ago
JavaScript
99%
MIT

AnythingLLM

AI Assistants · Automation · Developer Tools

67,496

The all-in-one AI platform for private document chat, no-code agents, and local LLMs with zero setup friction.

View details
91
Repo Health
78
Technical
65
Dependency
Built with
JavaScript 99%
Updated today
TypeScript
62%
Other

Flowise

AI Development · Automation · Developer Tools

55,521

Drag-and-drop visual builder for AI agents, RAG pipelines, and multi-agent systems—deploy anywhere in minutes.

View details
75
Repo Health
77
Technical
63
Dependency
Built with
TypeScript 62%
JavaScript 27%
Updated 2 months ago
TypeScript
53%
Apache 2.0

Flowsint

Automation · Developer Tools

9,911

A privacy-first, graph-based OSINT investigation platform with 30+ automated enrichers for mapping relationships between domains, IPs, people, and organizations.

View details
85
Repo Health
71
Technical
67
Dependency
Built with
TypeScript 53%
Python 45%
Updated 6 days ago
JavaScript
98%
Other

Markdrop

Note Taking

360

Visual drag-and-drop markdown editor with GitHub-specific blocks, cloud sync, and offline PWA support

View details
38
Repo Health
57
Technical
69
Dependency
Built with
JavaScript 98%
Updated 6 months ago
Python
55%
Other

PostHog

Ab Testing Experimentation · Analytics · Developer Tools

40,397

The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.

View details
92
Repo Health
80
Technical
65
Dependency
Built with
Python 55%
TypeScript 36%
Updated today
Rust
72%
Apache 2.0

Rivet

AI Agents · Developer Tools

6,326

Stateful actors as a primitive for AI agents, real-time collaboration, and durable execution — with in-memory state, WebSockets, queues, and scheduling built in.

View details
87
Repo Health
81
Technical
64
Dependency
Built with
Rust 72%
TypeScript 25%
Updated today
Python
79%
AGPL 3.0

Skyvern

AI Agents · Automation

23,257

Skyvern (YC S2023) automates browser-based workflows by pairing LLMs with computer vision, letting agents click, fill, and extract data on sites they've never seen, without brittle XPath selectors that break on every layout change.

View details
89
Repo Health
82
Technical
70
Dependency
Built with
Python 79%
TypeScript 19%
Updated today
HTML
68%
AGPL 3.0

ToolJet

AI Agents · Low Code Platforms · No Code Platforms

41,123

Open-source AI-native platform to build and deploy internal tools, workflows, and AI agents with a visual drag-and-drop builder and 80+ data source integrations.

View details
94
Repo Health
81
Technical
63
Dependency
Built with
HTML 68%
JavaScript 20%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers