Docs Getting started

Realtime in ten lines

Kumo is a realtime messaging SDK. Open a channel, publish a message, and every connected client gets it in under 50 milliseconds, anywhere on earth.

All systems normalv3.2.0Updated 2 days ago6 min read

Installation #

Kumo works in the browser, Node 18+, Bun, Deno and React Native. Pick your package manager.

$ npm install @kumo/sdk

TipThe SDK is 9.4 kB gzipped and has zero dependencies. It will not slow your bundle down.

Quickstart #

  1. Create a client

    Grab a publishable key from the dashboard. It is safe to ship in frontend code.

  2. Join a channel

    Channels are created on first use. Name them anything, like room:lobby.

  3. Publish and subscribe

    Every subscriber receives the message, including the sender.

chat.ts
import { Kumo } from '@kumo/sdk' const kumo = new Kumo({ key: 'pk_live_7c1e...', region: 'auto' })const room = kumo.channel('room:lobby') room.subscribe('message', (msg) => {  console.log(msg.data.text, 'from', msg.clientId)}) await room.publish('message', { text: 'Hello from Rajshahi' })// latency p50: 38 ms, p99: 91 ms

NoteHighlighted lines are the only ones you need. The rest is your app.

Authentication #

Publishable keys can subscribe. To publish from untrusted clients, mint a short-lived token on your server with the scopes the user needs.

server.js
const token = await kumo.auth.createToken({  clientId: user.id,  scopes: ['room:*:publish', 'room:*:presence'],  ttl: 3600 // seconds})

WarningNever ship a secret key (sk_) to the browser. Anyone could publish as you.

Channels #

A channel is a named stream of messages. Names use colons for namespaces, and scopes can match with wildcards like room:*.

Presence #

Presence tells you who is in a channel right now. Use it for online dots, live cursors and "typing" hints.

Message history #

Channels keep the last 24 hours of messages by default. Call room.history({ limit: 50 }) to backfill a chat window.

Edge regions #

Kumo runs in 41 regions. With region: 'auto', each client connects to the closest one and messages cross the backbone, not the public internet.

publish() #

Sends a message to every subscriber of the channel. Returns when the message is stored in at least two regions.

ParameterTypeDescription
eventrequiredstringEvent name. Subscribers filter by it.
datarequiredobjectAny JSON value up to 64 kB.
ttlnumberSeconds to keep in history. Default 86400.
echobooleanDeliver to the sender too. Default true.

subscribe() #

Registers a listener. Returns an unsubscribe function. Reconnects and replays missed messages for you.

Try it live #

This runs against a simulated sandbox right in your browser. Change the fields and press Send.

POST/v3/channels/room:lobby/messages
Waiting for a request
// Response appears here

Errors #

CodeMeaningWhat to do
401Missing or expired tokenMint a fresh token on your server.
403Token lacks the scopeAdd channel:publish to scopes.
413Message over 64 kBSend a URL to the blob instead.
429Rate limit hitBack off. The SDK retries with jitter.
Was this page helpful?Edit this page
Demo by Xiraiya