You use the Ditto JavaScript SDK to work with the Ditto HTTP API and WebSocket API from browser and Node.js environments.
@eclipse-ditto/ditto-javascript-client-dom for browsers or @eclipse-ditto/ditto-javascript-client-node for Node.js, then use the client to manage Things, subscribe to events, and send messages.Overview
The JavaScript SDK provides separate packages for different environments:
| Package | Environment | Description |
|---|---|---|
@eclipse-ditto/ditto-javascript-client-dom |
Browser (DOM) | Uses browser-native HTTP and WebSocket |
@eclipse-ditto/ditto-javascript-client-node |
Node.js | Uses Node.js HTTP and WebSocket |
@eclipse-ditto/ditto-javascript-client-api |
Any | API-only – build your own client implementation |
All released versions are published on npmjs.com.
Getting started
Installation
Install the package for your environment:
# For browser applications:
npm install @eclipse-ditto/ditto-javascript-client-dom
# For Node.js applications:
npm install @eclipse-ditto/ditto-javascript-client-node
Compatibility
The JavaScript SDK tracks the same major version as Eclipse Ditto. The latest release covers as much API functionality as possible for the corresponding Ditto version.
Building from source
npm install
npm run build
npm run lint
npm test
Troubleshooting build issues
If you encounter build errors, clean everything and start fresh:
npm run clean
# Delete node_modules in the root folder
npm install
npm run build
The build process uses lerna for multi-package management and rollup.js for generating multiple module formats (IIFE, ES Module, CommonJS). During install and build, lerna symlinks the api dependency into the dom and node packages.
Further reading
- @eclipse-ditto/ditto-javascript-client-dom README – browser usage details
- @eclipse-ditto/ditto-javascript-client-node README – Node.js usage details
- @eclipse-ditto/ditto-javascript-client-api README – API package details
- HTTP API overview – the REST API the SDK wraps
- WebSocket binding – the WebSocket transport