0.0.5 • Published 4 months ago

@shish2k/react-mqtt v0.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

React MQTT Tools

A provider and hook for subscribing to an MQTT topic

function MyStream(props) {
  const [msg, setMsg] = useState("");
  useSubscription(props.topic, (packet) => setMsg(packet.text()));

  return (
    <div>
      The most recent message on {props.topic} is {msg}
    </div>
  );
}

function App() {
  return (
    <MqttProvider url={"wss://test.mosquitto.org:8081/mqtt"}>
      <MyStream topic={"test"} />
    </MqttProvider>
  );
}

See demo.html for a self-contained, well-commented example.

0.0.3

4 months ago

0.0.5

4 months ago

0.0.4

4 months ago

0.0.2

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago