@altara/mqtt
v0.1.2
Published
MQTT-over-WebSocket adapter for React — subscribe to MQTT broker topics (sensors, IoT state, telemetry) and pipe live samples into real-time Altara dashboards. JSON / string / binary payloads, topic wildcards, auto-decode.
Maintainers
Readme
@altara/mqtt
MQTT-over-WebSocket adapter for Altara. Subscribe to an MQTT broker topic from React in one line and pipe live samples (sensor values, IoT state, telemetry) into any @altara/core component. Built for industrial-IoT dashboards, smart-building monitors, and home-automation HMIs.
Install
npm install @altara/core @altara/mqtt mqttmqtt is an optional peer dependency — install it only if you actually use MQTT. The browser build connects via ws:// or wss://.
Quick start
import { AltaraProvider, TimeSeries } from '@altara/core';
import { createMqttAdapter } from '@altara/mqtt';
const source = createMqttAdapter({
url: 'ws://broker.local:8083/mqtt',
topic: 'sensors/temp/room1',
// Pull a number out of each decoded message.
valueExtractor: (payload) => (payload as { celsius: number }).celsius,
});
export function App() {
return (
<AltaraProvider theme="dark">
<TimeSeries dataSource={source} height={240} />
</AltaraProvider>
);
}What you get
createMqttAdapter— typed factory that returns anAltaraDataSource. Auto-decodes JSON / string / binary payloads; supports MQTT topic wildcards (+,#).MqttAdapterOptions/MqttClientLike— the option bag and the minimal client interface, exported for advanced custom-transport scenarios.
Relationship to @altara/core
The implementation lives in @altara/core and is also exported from there. @altara/mqtt is a thin specialised re-export that mirrors @altara/ros — pulling it into a project is a clear signal that the app talks to an MQTT broker, and keeps the installation surface symmetrical across telemetry transports.
If you already depend on @altara/core, you can import { createMqttAdapter } from '@altara/core' directly with no behavioral difference.
Documentation
- 📚 Connecting MQTT guide (live Storybook) — broker setup, topic-wildcard routing, JSON vs binary payload handling, throttling, reconnection.
- 🛰️ Live demo dashboard — IoT-style components an MQTT feed would drive.
Or run Storybook locally:
git clone https://github.com/JayaSaiKishanChapparam/altara.git
cd altara
pnpm install
pnpm --filter @altara/storybook storybookThen open Guides → Connecting MQTT.
Sibling packages
| Package | What it does |
| --- | --- |
| @altara/core | Components, hooks, MQTT/mock adapters, design tokens. The starting point. |
| @altara/aerospace | Flight instruments — PFD, HSI, altimeter, airspeed, VSI, engine cluster, TCAS, TAWS, FMA, fuel gauge, radio altimeter. |
| @altara/ros | ROS2 / rosbridge adapter + typed factories for common sensor_msgs/* message types. |
Links
- Storybook (live) · Demo dashboard (live)
- GitHub repository
- Issue tracker
- Discussions
mqttpackage — the browser/Node MQTT client used under the hood
License
MIT — see LICENSE.
