Socket
Socket
Sign inDemoInstall

streamr-client-react

Package Overview
Dependencies
Maintainers
14
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

streamr-client-react

React toolkit for Streamr.


Version published
Weekly downloads
93
decreased by-75.13%
Maintainers
14
Weekly downloads
 
Created
Source

Streamr-client-react ✨

React hooks and components for streamr-client.

Installation

npm install streamr-client-react

Usage

The following example shows how to easily inject a StreamrClient instance into your app and log messages going through a selected stream.

import Provider, { useSubscription } from 'streamr-client-react'

const OhMyStreamr = () => {
    const onMessage = useCallback((message) => {
        console.log(message)
    }, [])

    useSubscription({
        stream: 'STREAM ID',
        // For more options see
        // https://github.com/streamr-dev/streamr-client-javascript#subscription-options
    }, onMessage)
}

const App = () => {
    const streamrClientOptions = {
        // For options see
        // https://github.com/streamr-dev/streamr-client-javascript#client-options
    }

    return (
        <Provider {...streamrClientOptions}>
            <OhMyStreamr />
        </Provider>
    )

useSubscription is a wrapper around client.subscribe and is built using useClient hook. Getting the client for arbitrary use is simple.

const OhMyStreamr = () => {
    const client = useClient()

    client.publish('STREAM ID', {
        temperature: 25.4,
    })
}

Refer to streamr-client for more options.

Keywords

FAQs

Package last updated on 16 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc