SDKs

QPub ships official client libraries for JavaScript/TypeScript, React, and Go. Use the API and Language controls to switch Socket vs REST and the sample language.

Install

npm install @qpub/sdk
ImportUse
@qpub/sdkQPub.Socket, QPub.Rest, types (JavaScript / TypeScript)
@qpub/sdk/reactReact providers and hooks (same npm package)
github.com/qpubio/qpub-goqpub.NewSocket, qpub.NewRest (Go)
CDN UMD (@qpub/sdk)Global QPub in the browser

Quick example

Use the Socket client for realtime subscribe and publish:

import { QPub } from "@qpub/sdk";

const socket = new QPub.Socket({
  apiKey: process.env.QPUB_API_KEY,
});

socket.connection.on("connected", async () => {
  const ch = socket.channels.get("news");
  await ch.subscribe((msg) => console.log(msg.data));
});

Do not put a production API key secret in a public browser app. Use token auth instead.

Next steps

Other languages

Use the REST API and Socket Protocol directly when no official SDK exists for your stack.