react-event-stream
TypeScript icon, indicating that this package has built-in type declarations

1.1.8 • Public • Published

react-event-stream is custom a React Hook that wraps built-in EventSource object.

npm CodeFactor npm bundle size NPM npm JavaScript Style Guide

react-event-stream simplifies to use Server Sent Events with built-in EventSource in your react application.

More information about server-sent-events.

🕺 Install

react-event-stream uses rxjs as peerDependency, so you have to install rxjs with react-event-stream.

by using npm:

$ npm i react-event-stream rxjs

by using yarn:

$ yarn add react-event-stream rxjs

Usage

import React from 'react'
import useEventStream from 'react-event-stream';

const Example = () => {
    const value = useEventStream('http://localhost:8080/sse', 1000);

    return (
        <>
            {JSON.stringify(value)};
        </>
    );
};

export default Example;

Made with

License

MIT © enesusta

Readme

Keywords

none

Package Sidebar

Install

npm i react-event-stream

Weekly Downloads

2

Version

1.1.8

License

MIT

Unpacked Size

7.83 kB

Total Files

14

Last publish

Collaborators

  • enesusta