EventSource

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

Library
npm
v5.1.2
1,159 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
85 /100 Excellent
Development Activity 96
Maintenance 72
Community 84
Maturity 60
Momentum 28

Technical Analysis

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

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

AI Code Assistants · Automation · Developer Tools

16,015

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
58
Repo Health
84
Technical
60
Dependency
Built with
TypeScript 96%
Updated 3 months ago
TypeScript
100%
MIT

Botpress

AI Assistants · AI Development · Customer Support

14,924

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
TypeScript 100%
Updated 1 weeks ago
TypeScript
97%
Other

GrowthBook

Ab Testing Experimentation · Analytics · Developer Tools

8,446

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
TypeScript 97%
Updated 5 days ago
TypeScript
82%
MIT

LibreChat

AI Assistants · Developer Tools

45,009

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
TypeScript 82%
JavaScript 17%
Updated 5 days ago
TypeScript
92%
Other

n8n

Automation · No Code Platforms

206,147

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
65
Dependency
Built with
TypeScript 92%
Updated 5 days ago
TypeScript
85%
GPL 3.0

Notesnook

File Storage · Note Taking · Security

14,660

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
TypeScript 85%
JavaScript 12%
Updated 6 days ago
TypeScript
96%
Other

Refly

AI Development · Automation · No Code Platforms

7,534

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

View details
62
Repo Health
76
Technical
63
Dependency
Built with
TypeScript 96%
Updated 2 months ago
Rust
72%
Apache 2.0

Rivet

AI Agents · Developer Tools

6,195

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
64
Dependency
Built with
Rust 72%
TypeScript 25%
Updated 1 weeks ago
TypeScript
88%
Other

strapi

CMS

73,243

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
TypeScript 88%
JavaScript 12%
Updated 6 days ago

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