@billionkeys/react-native-eventsource

React-Native component for EventSource: Server-Sent Events for iOS and Android

Usage no npm install needed!

<script type="module">
  import billionkeysReactNativeEventsource from 'https://cdn.skypack.dev/@billionkeys/react-native-eventsource';
</script>

README

react-native-eventsource

Dependencies Build License PRs Welcome

Description

A react-native component for EventSource: Server-Sent Events for iOS and Android.

Install

yarn add @billionkeys/react-native-eventsource

How to use it?

import EventSource from "@billionkeys/react-native-eventsource";

const url = "https://domain/sse";
const eventSource = new EventSource(url);

eventSource.onopen = () => {
  console.debug("onopen");
};
eventSource.onmessage = message => {
  console.debug(message);
};
eventSource.onerror = err => {
  console.error(err);
};

License

MIT © billionkeys