npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

precompiled-mqtt

v4.3.14-beta

Published

Precompiled version of mqtt for browser

Downloads

6,350

Readme

mqtt.js

Precompiled version of mqtt.js for browser

This package is a prebuild version of mqtt mqtt (npm) Github For using the mqtt in react we have to build using webpack which thorws dozens of error in webpack 5 and due to varying system environment. So the goal of this package is to able to use the official mqtt package directly without any additional work. Also while deploying our react project in AWS amplify do face lot of issue in setting up build configs so using this package those issues will be solved.

Important

Use lastest version or [email protected] which is the build of [email protected] please dont install any version prior to 4.3.12 those are buggy and not well tested.

Why this package?

Just to get rid of this build process for react

npm install -g webpack                    // Install webpack globally
npm install mqtt                          // Install MQTT library
cd node_modules/mqtt
npm install .                             // Install dev deps at current dir
webpack mqtt.js --output-library mqtt     // Build

This package had been tested only with React 17. But it should work with other frontend library as well.

NOTE : This package is replacement of [email protected]

Installation

npm i precompiled-mqtt

Example

This is a piece of peudo-code, please raise a issue if you find any

import mqtt from "precompiled-mqtt";

// mosquitto test broker
const URL = "mqtt://test.mosquitto.org:8081";

// Local broker
const URL = "ws://192.168.43.xx:1234";

const client = mqtt.connect(URL);

client.on('connect', () => {
    console.log("CONNECTED to broker");
});


const onMessage = (callBack) => {
    client.on("message", (topic, message, packet) => {
        callBack(JSON.parse(new TextDecoder("utf-8").decode(message)));
    });
}

For original documentation please refer to the official github repo of mqtt.js