# @haum/mqtt

> ## Example ```javascript

Latest version **2.1.1** (published 2021-01-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @haum/mqtt
pnpm add @haum/mqtt
yarn add @haum/mqtt
bun add @haum/mqtt
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2021-01-18 |
| First published | 2020-05-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Henrik Næss |
| Maintainers | haum |

## Links

- npm: https://www.npmjs.com/package/@haum/mqtt
- npm.io page: https://npm.io/package/@haum/mqtt

## Dependencies (3)

- [mqtt](https://npm.io/package/mqtt.md) ^4.2.6
- [pino](https://npm.io/package/pino.md) ^6.8.0
- [nanoid](https://npm.io/package/nanoid.md) ^3.1.20

## Recent versions

- 2.1.1 (latest) — 2021-01-18
- 2.0.1 — 2020-12-14
- 2.0.0 — 2020-12-14
- 1.1.2 — 2020-05-19
- 1.1.1 — 2020-05-19
- 1.0.1 — 2020-05-18
- 1.0.0 — 2020-05-18

## README

# @haum/mqtt

## Example
```javascript

// Connect to mqtt://localhost:1883 as "usr" with password "pwd"
const mqtt = require('.')({
  url: 'mqtt://localhost:1883',
  auth: {
    username: 'usr',
    password: 'pwd'
  }
});

// Subscribe to foo
let sub = mqtt.sub('foo', (topic, payload) => {
  console.log(topic, payload)
});

// Publish bar to foo
mqtt.pub('foo', 'bar');

// Unsubscribe from foo
mqtt.unsub(sub);
```

---
_Source: https://npm.io/package/@haum/mqtt · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
