Getting Started
Installation
Install the @cloudsignal/mqtt-client package via npm, yarn, or pnpm.
@cloudsignal/mqtt-client is the official CloudSignal MQTT WebSocket client for browser and Node.js. Install it from npm with your package manager of choice.
Install
The package resolves to the latest published version (@latest) by default.
npm install @cloudsignal/mqtt-clientyarn add @cloudsignal/mqtt-clientpnpm add @cloudsignal/mqtt-clientBrowsers without a bundler
For HTML-first pages that don't use a bundler, load the IIFE bundle from unpkg. The unversioned path resolves to the latest published bundle.
<script src="https://unpkg.com/@cloudsignal/mqtt-client/dist/index.global.js"></script>The bundle exposes CloudSignal on the global namespace:
const client = new CloudSignal.default({
organizationId: 'your-org-id',
});Package formats
The library ships with three bundle formats. Your bundler picks the right one based on your import style.
| Format | Path | Use case |
|---|---|---|
| ESM | dist/index.js | Modern bundlers and ES modules |
| CJS | dist/index.cjs | Node.js require() usage |
| IIFE | dist/index.global.js | Browser <script> tags |
Requirements
| Environment | Minimum version |
|---|---|
| Browser | Modern browsers with WebSocket support |
| Node.js | v16 or later (for server-side usage) |
TypeScript support
TypeScript definitions are bundled with the package. No additional @types/* install is needed.
import { CloudSignalClient, CloudSignalConfig } from '@cloudsignal/mqtt-client';
const config: CloudSignalConfig = {
organizationId: 'your-org-id',
debug: true,
};
const client = new CloudSignalClient(config);