Skip to content

Instantly share code, notes, and snippets.

Created Nov 2, 2021
What would you like to do?
Simple example showing how to add MQTT to your React app
import logo from './logo.svg';
import './App.css';
import { Connector } from 'mqtt-react-hooks';
import Status from './Status';
const mqttOptions = {
username: 'username',
password: 'password', // Passwords are buffers
function App() {
return (
<Connector brokerUrl="ws://" options={mqttOptions}>
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
Edit <code>src/App.js</code> and save to reload.
rel="noopener noreferrer"
Learn React
<Status />
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment