Node version: 18.17.1 Npm version: 9.8.1
I have successfully installed the mqtt package using the following command:
npm install mqtt
The installation is working perfectly without any issues. Here is a snippet of the code:
import { useState } from 'react'
import './App.css'
import * as mqtt from 'mqtt'
function App() {
let client = mqtt.connect("mqtt://test.mosquitto.org"); // create a client
return (
<>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
</>
)
}
export default App
An error message is being displayed which can be viewed here.
- Successfully connected to MQTT broker from Javascript
- Failed to connect to MQTT broker from Vite (React)
- Failed to connect to MQTT broker from Next.js