# iothub-browser

> * Receives Cloud-to-device messages * Sends Device-to-cloud messages * Monitors all IotHub Messages

Latest version **1.3.0** (published 2018-09-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install iothub-browser
pnpm add iothub-browser
yarn add iothub-browser
bun add iothub-browser
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2018-09-27 |
| First published | 2018-07-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 104.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Hao Luo |
| Maintainers | howlowck |
| Keywords | iothub, eventhub, browser, device, iot |

## Links

- npm: https://www.npmjs.com/package/iothub-browser
- Repository: https://github.com/howlowck/iothub-browser
- Homepage: https://github.com/howlowck/iothub-browser#readme
- Issues: https://github.com/howlowck/iothub-browser/issues
- npm.io page: https://npm.io/package/iothub-browser

## Dependencies (4)

- [mqtt](https://npm.io/package/mqtt.md) ^2.18.3
- [rhea](https://npm.io/package/rhea.md) ^0.2.17
- [debug](https://npm.io/package/debug.md) ^3.1.0
- [create-hmac](https://npm.io/package/create-hmac.md) ^1.1.7

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.3.0 (latest) — 2018-09-27
- 1.2.0 — 2018-09-06
- 1.1.0 — 2018-07-20
- 1.0.1 — 2018-07-03
- 1.0.0 — 2018-07-03

## README

# IotHub Browser Only Package

## Features:
* Receives Cloud-to-device messages
* Sends Device-to-cloud messages
* Monitors all IotHub Messages

## Install
Run `npm install --save-dev iothub-browser`

## How to Use IotHub Device(in the browser)
Assuming you are using a bundler like browserify or webpack

```js
import {connectDevice} from 'iothub-browser'

const {publish, close} = connectDevice('{device connection string from iothub}', (topic, c2dMessage) => {
  console.log(c2dMessage)
})

publish(JSON.stringify({message: "hello world"}), {prop1: "looks good"})

// ... to close the connection
close()
```

## How to Use Event Monitoring

Event Monitoring uses the `events` Iothub endpoint which is a eventhub-compatible endpoint.

```js
import {monitorEvents} from 'iothub-browser'

const {close} = monitorEvents('{eventhub-name}', '{eventhub-compatible-connection-string}', (message, context) => {
  console.log(message)
  console.log(context)
})

// ... to close the monitor connection

close()
```

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