Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Node.js
  3. MQTT.js

MQTT.js

NOASSERTIONTypeScriptv5.15.1

A full-featured MQTT client library for Node.js and the browser, written in TypeScript.

GitHubGitHub
9.1k stars1.4k forks0 contributors

What is MQTT.js?

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.

Target Audience

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.

Value Proposition

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.

Overview

The MQTT client for Node.js and the browser

Use Cases

Best For

  • Building IoT device clients that communicate with MQTT brokers
  • Creating real-time web applications using MQTT over WebSockets
  • Developing cross-platform mobile apps with React Native requiring MQTT
  • Implementing pub-sub messaging in Node.js microservices
  • Prototyping MQTT 5.0 features like topic aliases or custom properties
  • Integrating with MQTT brokers in WeChat or Ali Mini Programs

Not Ideal For

  • Production systems requiring stable, non-experimental MQTT 5.0 support
  • Browser applications dependent on detailed WebSocket error diagnostics for debugging
  • Teams prioritizing long-term stability over frequent, breaking major updates
  • Projects with stringent bundle size constraints where lighter alternatives exist

Pros & Cons

Pros

Cross-Platform Versatility

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.

Robust Reconnection Logic

Offers configurable automatic reconnection with hooks like transformWsUrl for refreshing authentication tokens, ensuring reliable connectivity in unstable networks.

Advanced MQTT Features

Supports MQTT 5.0 features like topic alias management and custom properties, along with QoS 0-2, providing flexibility for optimized messaging workflows.

TypeScript Native

Rewritten in TypeScript from v5.0.0, with built-in type definitions that enhance developer experience through autocompletion and error checking.

Flexible API Design

Provides both callback-based and promise-based async methods (e.g., publishAsync, subscribeAsync) for publishing and subscribing, catering to different coding styles.

Cons

Experimental MQTT 5.0

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.

Browser Error Handling Gaps

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.

Breaking Changes Burden

Major versions like v5.0.0 introduce breaking changes (e.g., requiring 'new' for MqttClient), forcing teams to update codebases and potentially causing disruptions.

Frequently Asked Questions

Quick Stats

Stars9,058
Forks1,445
Contributors0
Open Issues30
Last commit28 days ago
CreatedSince 2011

Tags

#iot#hacktoberfest#reconnection#mqtt#mqtt-broker#mqtt-client#nodejs#typescript#javascript#nodejs-library#pub-sub#browser#real-time-messaging#websockets

Built With

W
WebSocket
T
TypeScript
N
Node.js
e
esbuild

Included in

Node.js65.5k
Auto-fetched 1 day ago

Related Projects

Socket.ioSocket.io

Realtime application framework (Node.JS server)

Stars63,050
Forks10,153
Last commit7 days ago
uWebSocketsuWebSockets

Simple, secure & standards compliant web server for the most demanding of applications

Stars18,806
Forks1,850
Last commit1 day ago
SocketClusterSocketCluster

Highly scalable realtime pub/sub and RPC framework

Stars6,198
Forks323
Last commit1 day ago
PrimusPrimus

:zap: Primus, the creator god of the transformers & an abstraction layer for real-time to prevent module lock-in.

Stars4,472
Forks269
Last commit2 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub