Skip to content

falcondev-oss/expo-event-source-polyfill

Repository files navigation

Expo EventSource polyfill

This package provides a polyfill for the EventSource API in Expo using expo/fetch. By using Expo's fetch implementation we don't rely on polling as a workaround since it supports streaming out of the box.

Warning

Only works with Expo v52 and above.

Installation

npm install @falcondev-oss/expo-event-source-polyfill

Usage

Create an index.js file in the root of your project with the following content:

import { ExpoEventSource } from '@falcondev-oss/expo-event-source-polyfill'
// @ts-expect-error this is used internally and the recommended way to polyfill global objects
import { polyfillGlobal } from 'react-native/Libraries/Utilities/PolyfillFunctions'

import 'expo-router/entry'

polyfillGlobal('EventSource', () => ExpoEventSource)

Then, add the following to your package.json:

{
  "main": "index.js"
}

About

A polyfill for the EventSource API in Expo using `expo/fetch`

Resources

License

Stars

Watchers

Forks

Packages

No packages published