Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@sanity/eventsource

sanity-io1.5mMIT5.0.2TypeScript support: included

EventSource polyfill for browser and node.js

sanity, cms, headless, realtime, content, eventsource, polyfill

readme

@sanity/eventsource

npm stat npm version gzip size size

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

npm install @sanity/eventsource

Usage

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 package. While browsers use 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:

import polyfilledEventSource from '@sanity/eventsource/browser'

To force the Node implementation, use the following:

import polyfilledEventSource from '@sanity/eventsource/node'

License

MIT © Sanity.io

changelog

📓 Changelog

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

5.0.2 (2024-04-22)

Bug Fixes

5.0.1 (2023-09-28)

Bug Fixes

  • deps: update dependency @types/event-source-polyfill to v1.0.2 (bb87c96)
  • deps: update dependency @types/eventsource to v1.1.12 (#39) (e312938)

5.0.0 (2023-03-22)

⚠ BREAKING CHANGES

  • you may need to remove custom declare module '@sanity/eventsource' instances in your codebase

Features

  • add TypeScript definitions (eb9076a)

4.1.1 (2023-03-22)

Bug Fixes

  • deps: update dependency event-source-polyfill to v1.0.31 (f385961)
  • rollback TS (6803c69)

4.1.0 (2023-03-22)

Features