This library is focused to help you to connect, publish and subscribe to a Message Queuing Telemetry Transport (MQTT) in ReactJS with the power of React Hooks. The library is a modification of mqtt-react-hooks found here.
- WiFi or other mobile sensors publish data to an MQTT broker
- ReactJS subscribes to the MQTT broker and receives the data using MQTT.js
- React's state is updated, and the data is passed down to stateless components
- useMqttState -> return { status, mqtt }
- useSubscription(topic) -> return { mqtt, status, lastMessage }
Currently, mqtt-react-hooks exports one enhancers.
Similarly to react-redux, you'll have to first wrap a root component with a
Connector
which will initialize the mqtt instance.