# @sanity/eventsource

> EventSource polyfill for browser and node.js

Latest version **5.0.4** (published 2026-07-15) · MIT license · 930.8K weekly downloads

## Install

```sh
npm install @sanity/eventsource
pnpm add @sanity/eventsource
yarn add @sanity/eventsource
bun add @sanity/eventsource
```

## Health

**Score 90/100 (A)** — status: active.

Positive: moderate downloads; has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

## Facts

| | |
|---|---|
| Version | 5.0.4 |
| Published | 2026-07-15 |
| First published | 2016-10-28 |
| Weekly downloads | 930.8K |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 5.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 2 |
| Author | Sanity.io |
| Maintainers | sanity-svc.npm, sanity-io |
| Keywords | sanity, cms, headless, realtime, content, eventsource, polyfill |

## Links

- npm: https://www.npmjs.com/package/@sanity/eventsource
- Repository: https://github.com/sanity-io/eventsource
- Homepage: https://www.sanity.io/
- Issues: https://github.com/sanity-io/sanity/issues
- npm.io page: https://npm.io/package/@sanity/eventsource

## Dependencies (4)

- [eventsource](https://npm.io/package/eventsource.md) 2.0.2
- [@types/eventsource](https://npm.io/package/@types/eventsource.md) 1.1.15
- [event-source-polyfill](https://npm.io/package/event-source-polyfill.md) 1.0.31
- [@types/event-source-polyfill](https://npm.io/package/@types/event-source-polyfill.md) 1.0.5

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [node-jose](https://npm.io/package/node-jose.md) — 908.8K weekly downloads

## Recent versions

- 5.0.4 (latest) — 2026-07-15
- 6.0.0-canary.2 (canary) — 2024-04-24
- 3.0.3 (previous) — 2022-05-30
- 2.23.0-event-source-yaffle.0 (event-source-yaffle-0) — 2022-02-16
- 2.23.0-event-source-yaffle (event-source-yaffle) — 2022-02-16
- 2.27.1-cookieless-tag.19 (cookieless-tag) — 2022-02-16
- 2.27.1-client-update.18 (client-update) — 2022-02-16
- 2.27.1-new-cookieless.18 (new-cookieless) — 2022-02-16
- 2.27.1-event-source-monorepo.17 (event-source-monorepo) — 2022-02-16
- 2.27.1-updated-client-w-polyfill-2.18 (updated-client-w-polyfill-2) — 2022-02-16
- 2.27.1-updated-client-w-polyfill-1.18 (updated-client-w-polyfill-1) — 2022-02-16
- 2.27.1-updated-client-w-polyfill.18 (updated-client-w-polyfill) — 2022-02-16
- 2.27.1-updated-polyfil-client.18 (updated-polyfil-client) — 2022-02-15
- 2.27.1-eventsource-for-client.17 (eventsource-for-client) — 2022-02-15
- 2.27.1-event-source-tag.17 (event-source-tag) — 2022-02-15
- … 552 more at https://npm.io/package/@sanity/eventsource/versions

## README

# @sanity/eventsource

[![npm stat](https://img.shields.io/npm/dm/@sanity/eventsource.svg?style=flat-square)](https://npm-stat.com/charts.html?package=@sanity/eventsource)
[![npm version](https://img.shields.io/npm/v/@sanity/eventsource.svg?style=flat-square)](https://www.npmjs.com/package/@sanity/eventsource)
[![gzip size][gzip-badge]][bundlephobia]
[![size][size-badge]][bundlephobia]

Meta-package to make browsers and Node use different EventSource polyfills

```sh
npm install @sanity/eventsource
```

## Usage

```ts
import polyfilledEventSource from '@sanity/eventsource'
```

The polyfill adds support for auth headers, which isn't part of the EventSource spec.

In NodeJS environments it's the implementation from [eventsource](https://www.npmjs.com/package/eventsource) package. While browsers use [event-source-polyfill](https://www.npmjs.com/package/event-source-polyfill).

### Forcing a specific implementation

To get the browser implementation, no matter how your bundler or runtime understands `package.json` `exports`, you can use the following:

```ts
import polyfilledEventSource from '@sanity/eventsource/browser'
```

To force the Node implementation, use the following:

```ts
import polyfilledEventSource from '@sanity/eventsource/node'
```

## License

MIT © [Sanity.io](https://www.sanity.io/)

[gzip-badge]: https://img.shields.io/bundlephobia/minzip/@sanity/eventsource?label=gzip%20size&style=flat-square
[size-badge]: https://img.shields.io/bundlephobia/min/@sanity/eventsource?label=size&style=flat-square
[bundlephobia]: https://bundlephobia.com/package/@sanity/eventsource

---
_Source: https://npm.io/package/@sanity/eventsource · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
