EventSource

WhatWG/W3C-compliant EventSource (Server-Sent Events) client for JS runtimes

Library
npm
v5.1.1
1,156stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
82/100Excellent
Development Activity84
Maintenance72
Community84
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
75/100Good
Architecture75
Code Quality78
Innovation65
Learning Curve82

eventsource is a minimal, spec-compliant implementation of the WhatWG/W3C EventSource API for environments that don’t ship one natively — Node.js, Bun, Deno, and older browsers. It parses text/event-stream responses into typed message/custom events with automatic reconnection, matching the exact behavior defined by the living standard rather than adding an opinionated API on top.

Because it builds on fetch and ReadableStream instead of raw sockets, it accepts a pluggable fetch implementation — letting consumers add custom headers, proxy support, or HTTP/2 via libraries like undici without forking the client.

What You Get

  • A EventSource class implementing the full WhatWG event-stream parsing and reconnection spec
  • Custom event listening via addEventListener('eventType', handler) for named SSE event types
  • A pluggable fetch option for adding auth headers, proxies (via undici), or HTTP/2 support
  • Extended error events exposing message and HTTP code for diagnosing failed connections
  • Support across Node.js 20+, Bun, Deno, and all evergreen browsers

Common Use Cases

  • Consuming a server-sent-events API from a Node.js backend or CLI tool
  • Streaming LLM/chat completions token-by-token from a server that emits SSE
  • Adding authentication headers or a corporate proxy to an SSE connection via a custom fetch
  • Polyfilling EventSource in test environments or older browsers that lack native support

Under The Hood

Architecture: The library is a thin, spec-faithful wrapper: src/EventSource.ts (605 lines) extends the native EventTarget, delegates stream parsing to the separate eventsource-parser package via createParser, and drives reconnection/backoff itself, while src/errors.ts and src/types.ts define the typed error and fetch-abstraction surface — there’s no framework or DI, just one class implementing a W3C state machine.

Tech Stack: TypeScript compiled to dual ESM/CJS output via pkg-utils, with zero runtime dependencies beyond eventsource-parser. It deliberately depends on fetch, ReadableStream, and TextDecoder rather than Node’s http module, which is what lets the same code run unmodified on Node 20+, Bun, Deno, and browsers.

Code Quality: Test suites are split per-runtime (test/node, test/browser, test/bun, test/deno), each run through tsx or the runtime’s own test runner, and posttest chains ESLint plus a strict tsc --noEmit — a deliberate choice to catch cross-runtime type drift rather than relying on a single Node-only test pass.

API Design: The public API is intentionally a strict subset of the browser standard (CONNECTING/OPEN/CLOSED constants, addEventListener, .close()) with one pragmatic extension — a fetch constructor option — that avoids inventing new concepts, so migrating code that used to run only in the browser is close to a drop-in exercise, backed by an explicit MIGRATION.md for v2→v3 users.

Used by 10 apps in this directory

TypeScript
96%
Other

Amplication

Developer Tools · AI Code Assistants · Automation

16,011

Create production-ready backend services with your organization's standards baked in — generating NestJS, Prisma, and GraphQL code that you own and control.

View details
60
Repo Health
84
Technical
60
Dependency
Built with
TypeScript96%
Updated 2 months ago
TypeScript
100%
MIT

Botpress

AI Assistants · AI Development · Customer Support

14,893

The open-source hub for building and deploying LLM-powered AI agents with TypeScript-first tooling, 40+ integrations, and a revolutionary code-execution agent framework.

View details
94
Repo Health
82
Technical
64
Dependency
Built with
TypeScript100%
Updated 3 days ago
TypeScript
97%
Other

GrowthBook

Developer Tools · Analytics · Monitoring

8,299

Open source feature flags, A/B testing, and warehouse-native experimentation that queries your existing data infrastructure—no data movement required.

View details
92
Repo Health
85
Technical
63
Dependency
Built with
TypeScript97%
Updated yesterday
TypeScript
81%
MIT

LibreChat

Developer Tools · AI Assistants

42,871

Unite every major AI model in one self-hosted chat platform with agents, code execution, MCP tools, and enterprise authentication.

View details
93
Repo Health
81
Technical
65
Dependency
Built with
TypeScript81%
JavaScript18%
Updated today
TypeScript
92%
Other

n8n

Automation · No Code Platforms

203,555

Code when you need it, UI when you don't — the workflow automation platform built for technical teams who refuse to choose.

View details
95
Repo Health
87
Technical
66
Dependency
Built with
TypeScript92%
Updated today
TypeScript
85%
GPL 3.0

Notesnook

Note Taking · File Storage · Security

14,533

End-to-end encrypted, open-source note-taking where your data stays yours — even from the server.

View details
90
Repo Health
84
Technical
60
Dependency
Built with
TypeScript85%
JavaScript12%
Updated 2 days ago
TypeScript
96%
Other

Refly

No Code Platforms · AI Development · Automation

7,502

Build deterministic, versioned agent skills from natural language—run them anywhere from Claude Code to Slack.

View details
64
Repo Health
76
Technical
63
Dependency
Built with
TypeScript96%
Updated 1 months ago
Rust
71%
Apache 2.0

Rivet

AI Agents · Developer Tools

6,116

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
86
Repo Health
81
Technical
65
Dependency
Built with
Rust71%
TypeScript25%
Updated yesterday
TypeScript
88%
Other

strapi

CMS

73,083

Open-source headless CMS that auto-generates REST and GraphQL APIs from your content models, with a fully customizable admin panel you control.

View details
93
Repo Health
84
Technical
66
Dependency
Built with
TypeScript88%
JavaScript12%
Updated yesterday

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

Search