Skip to content
Get Started Playground

TypeScript SDK

The ZeroHub provides a TypeScript Client SDK to make it simple and type-safe to use the API.

Terminal window
npm install @zero-hub/client

Import the SDK and initialize the client

import { MeshTopology, ZeroHubClient, LogLevel } from "@zero-hub/client";
const zh = new ZeroHubClient(
["sg1.zerohub.dev"], // ZeroHub host
{ logLevel: LogLevel.Debug },
undefined,
new MeshTopology(undefined, (peer, dataChannel, isOwner) => {
// dataChannel is the dataChannel from peer
dataChannel.onmessage = (ev: MessageEvent) => {
// event message from peers
};
})
);