npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@olivvein/superhub-sdk

v0.1.2

Published

TypeScript client SDK for SuperHub over WebSocket/HTTPS.

Readme

superhub-sdk

TypeScript client SDK for SuperHub over WebSocket/HTTPS.

npm package: @olivvein/superhub-sdk

Install

npm install @olivvein/superhub-sdk
import { HubClient } from "@olivvein/superhub-sdk";

Quickstart (Node.js)

import { randomUUID } from "node:crypto";
import { HubClient } from "@olivvein/superhub-sdk";

const client = new HubClient({
  httpUrl: "https://code.samlepirate.org",
  token: process.env.HUB_TOKEN,
  clientId: randomUUID(),
  serviceName: "demo-node-client",
  consumes: ["demo.*"],
  debug: true
});

client.onOpen(() => {
  console.log("connected");

  const stopSub = client.subscribe({ namePrefix: "demo." }, (msg) => {
    console.log("event", msg.name, msg.payload);
  });

  client.publish("demo.ping", { at: Date.now() });

  setTimeout(() => {
    stopSub();
    client.disconnect();
  }, 10_000);
});

client.onError((err) => console.error("hub error", err));
client.onClose(() => console.log("disconnected"));

void client.connect();

Quickstart (Browser)

import { HubClient } from "@olivvein/superhub-sdk";

const client = new HubClient({
  httpUrl: "https://code.samlepirate.org",
  token: "<hub-token>",
  clientId: `web-${crypto.randomUUID()}`,
  serviceName: "demo-web-client",
  consumes: ["demo.*"]
});

await client.connect();
client.publish("demo.hello", { from: "browser" });

Configuration

HubClient options:

  • httpUrl (required): Hub base URL, for example https://code.samlepirate.org.
  • clientId (required): stable or random client ID.
  • token: hub token (X-Hub-Token equivalent, sent in WS query string).
  • wsUrl: override WebSocket URL (default derived from httpUrl as /ws).
  • serviceName: logical service name for routing/RPC.
  • version: advertised version in presence payload.
  • provides: service capabilities this client provides.
  • consumes: event patterns this client consumes.
  • tags: free-form metadata tags.
  • debug: verbose SDK logs for parsing/reconnect issues.
  • defaultRpcTimeoutMs: default RPC timeout (default 15000).
  • reconnect.enabled: auto reconnect toggle (default true).
  • reconnect.minDelayMs, maxDelayMs, factor, jitterRatio: reconnect backoff tuning.
  • tls.caFile (Node only): path to CA certificate file.
  • tls.rejectUnauthorized (Node only): set false only for local/debug environments.

Core API

Connection lifecycle

  • await client.connect()
  • client.disconnect()
  • client.onOpen(listener)
  • client.onClose(listener)
  • client.onError(listener)

Pub/Sub

  • client.publish(name, payload, target = "*", schemaVersion = 1)
  • const unsubscribe = client.subscribe({ names? | namePrefix? }, handler)

Target can be:

  • "*" (broadcast)
  • { clientId: "..." }
  • { serviceName: "..." }

RPC client

const result = await client.rpc<{ accepted: boolean }>(
  "music",
  "music.play",
  { trackId: "track-1", positionMs: 0 },
  5000
);

RPC server/provider

const unregister = client.onRpc("music.play", async (args, ctx) => {
  return {
    accepted: true,
    args,
    from: ctx.source
  };
});

State helpers

  • await client.getState<T>(path)
  • client.setState(path, value)
  • client.patchState(path, patchOps)
  • const unwatch = client.watchState(prefix, (path, value, source) => { ... })

Important behavior

  • Calls that send messages (publish, subscribe, setState, patchState, watchState, rpc) require an open socket.
  • If the socket is not connected, the SDK throws Error("Socket is not connected").
  • On reconnect, existing subscriptions and state watches are replayed automatically.

Examples

Scaffold bundled examples into your project:

npx --no-install superhub-examples ./superhub-examples

Generated files include Node and React examples.

Release / Publish (maintainers)

From monorepo root:

npm_config_cache=/tmp/.npm-cache npm whoami || npm_config_cache=/tmp/.npm-cache npm login
npm run release:sdk:patch
# or: npm run release:sdk:minor
# or: npm run release:sdk:major

Publish only (already version-bumped):

npm run publish:sdk

Full runbook:

  • docs/SDK_NPM_PUBLISH_GUIDE.md