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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@venn-lang/mqtt

v0.9.0

Published

The mqtt namespace: connect to a broker, publish, subscribe, wait for a message on a topic.

Readme

@venn-lang/mqtt

The mqtt namespace: connect to a broker, publish, subscribe, wait for a message on a topic.

Venn's grammar knows no verbs. @venn-lang/mqtt registers the mqtt namespace with the runtime, so mqtt.publish resolves to an action and mqtt.expect hands back a typed message. The connection and the subscriptions live behind the MqttClient port, not in a handle the flow carries around, so a host swaps the whole transport by binding a different implementation.

Install

Nothing to install yet. The package is unpublished (version 0.0.0) and ships inside @venn-lang/stdlib, which the venn CLI and the language server both load. A .vn file declares it:

import { mqtt } from "venn/mqtt"

Usage

module demo.inventory

import { mqtt } from "venn/mqtt"
import { topic } from "venn/mqtt"

flow "Inventory" {
  step "the broker relays the stock change" {
    mqtt.connect "mqtt://broker.test:1883"
    mqtt.subscribe "inventory/sku-42"
    mqtt.publish "inventory/sku-42" { json: { delta: -1 }, qos: 1 }

    const msg = mqtt.expect "inventory/sku-42"
    expect msg topic "inventory/sku-42"
    expect msg.payload.delta == -1
  }
}

API

Everything below is exported from the package barrel.

| Export | What it is | | --- | --- | | mqttPlugin (also the default export) | The PluginDefinition: namespace mqtt, requires: ["net"]. | | MqttClientPort | Port<MqttClient>, id venn.port.mqtt-client, version 1, methods connect, publish, subscribe, expect. | | createFakeMqttClient({ seed }) | The double: a topic-to-queue map that records publishes and subscriptions. | | createRealMqttClient() | The real client. Out of scope for this build: every method throws VN8090. | | mqttTypeDefs | What the plugin publishes to the checker, as TypeSpec data. |

Types: MqttClient, FakeMqttClient, MqttPublishArgs, MqttMessage.

Verbs

| Verb | Shape | Result | | --- | --- | --- | | mqtt.connect | mqtt.connect broker | nothing | | mqtt.publish | mqtt.publish topic { json, qos, retain, will } | nothing | | mqtt.subscribe | mqtt.subscribe topic | nothing | | mqtt.expect | mqtt.expect topic | mqtt.Message |

Each verb takes one positional argument: the broker URL for connect, the topic (wildcards and all) for the other three. Only publish has an options map, and it carries json (the payload), qos, retain and will.

subscribe hands nothing back: the subscription is the port's to remember, and mqtt.expect is how a flow reaches what arrived.

Matchers and types

topic is the one matcher: expect msg topic "inventory/ack" passes when the message arrived on that topic.

The plugin publishes one type, mqtt.Message, with topic, payload, and optional qos and retain. It is what mqtt.expect hands back, and what tells the checker that msg can carry the topic matcher.

Ports and conformance

MqttClient has the two implementations every port has, and both run src/clients/mqtt-client.suite.ts:

  • createRealMqttClient() is a stub in this build. Every method raises VN8090.
  • createFakeMqttClient({ seed }) keeps one queue per topic. A publish is recorded on published (with its qos, retain and will) and enqueued, so a publish-then-expect flow resolves without a broker. Subscriptions land on subscriptions.
import { createFakeMqttClient } from "@venn-lang/mqtt";

const client = createFakeMqttClient();
await client.subscribe({ topic: "inventory/ack" });
await client.publish({ topic: "inventory/ack", payload: { ok: true }, qos: 1 });
const message = await client.expect({ topic: "inventory/ack" });
// message.payload === { ok: true }

expect on an empty topic raises VN8091. @venn-lang/stdlib binds the fake by default, so the flow in Usage runs offline with no host wiring at all.

See also