A full-featured MQTT client library for Node.js and the browser, written in TypeScript.
MQTT.js is a client library for the MQTT (Message Queuing Telemetry Transport) protocol, enabling applications to communicate with MQTT brokers for publish/subscribe messaging. It solves the need for a reliable, cross-platform MQTT implementation in JavaScript, supporting features like QoS, reconnection, and MQTT 5.0 extensions.
JavaScript developers building IoT applications, real-time dashboards, or any system requiring lightweight messaging between devices and servers, particularly in Node.js or browser environments.
Developers choose MQTT.js for its comprehensive protocol support, active maintenance, and flexibility across platforms—from servers to mini-programs—backed by a strong open-source community and TypeScript-native development.
The MQTT client for Node.js and the browser
Works seamlessly across Node.js, browsers, React Native, and mini-programs like WeChat and Ali, with dedicated protocol support (e.g., wxs, alis) as documented in the README.
Offers configurable automatic reconnection with hooks like transformWsUrl for refreshing authentication tokens, ensuring reliable connectivity in unstable networks.
Supports MQTT 5.0 features like topic alias management and custom properties, along with QoS 0-2, providing flexibility for optimized messaging workflows.
Rewritten in TypeScript from v5.0.0, with built-in type definitions that enhance developer experience through autocompletion and error checking.
Provides both callback-based and promise-based async methods (e.g., publishAsync, subscribeAsync) for publishing and subscribing, catering to different coding styles.
The README explicitly notes MQTT 5.0 support is experimental and not fully implemented by brokers, making it risky for production reliance on new features.
Due to browser security restrictions, many WebSocket errors cannot be caught via client.on('error'), complicating debugging in web environments as admitted in the README.
Major versions like v5.0.0 introduce breaking changes (e.g., requiring 'new' for MqttClient), forcing teams to update codebases and potentially causing disruptions.
Realtime application framework (Node.JS server)
Simple, secure & standards compliant web server for the most demanding of applications
Highly scalable realtime pub/sub and RPC framework
:zap: Primus, the creator god of the transformers & an abstraction layer for real-time to prevent module lock-in.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.