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

@lachong-university/socketio-hub

v0.1.0

Published

Core Socket.IO SDK for socketio-hub.

Downloads

195

Readme

socketio-hub

Core SDK for creating typed Socket.IO clients with a small event bus for framework wrappers.

import { createSocketHub } from "@lachong-university/socketio-hub";

type ServerEvents = {
  "message:new": { roomId: string; text: string };
};

type ClientEvents = {
  "message:send": { roomId: string; text: string };
};

const hub = createSocketHub<ServerEvents, ClientEvents>({
  url: "https://realtime.example.com",
  namespace: "/chat",
  auth: async () => ({ token: "access-token" }),
  reconnect: true,
  timeout: 10000,
  debug: false,
});

await hub.connect();

hub.on("message:new", (payload) => {
  console.log(payload.roomId, payload.text);
});

await hub.emit("message:send", {
  roomId: "general",
  text: "Hello realtime",
});

API

  • connect() creates and connects the Socket.IO client.
  • disconnect() closes the active socket.
  • emit(event, payload) sends typed events to the server.
  • on(event, handler), once(event, handler), and off(event, handler) manage SDK listeners.
  • listen(listener) subscribes to every SDK event, including lifecycle events such as hub:connected, hub:disconnected, hub:state, and hub:error.
  • cleanup() removes Socket.IO listeners, disconnects, and clears the local event bus.

Browser Script

Build the package to generate browser-ready files:

pnpm --filter @lachong-university/socketio-hub build

Then include the global bundle directly in any web page or upload it to your CDN/S3 bucket:

<script src="https://cdn.example.com/socketio-hub.global.min.js"></script>
<script>
  const hub = SocketIOHub.createSocketHub({
    url: "https://realtime.example.com",
    namespace: "/chat",
    auth: { token: "access-token" },
  });

  hub.on("message:new", function (payload) {
    console.log(payload);
  });

  hub.connect();
</script>

The browser bundle exposes every public export on window.SocketIOHub.

You can also open examples/browser.html after building to verify the script-tag flow locally.

For module scripts, import the browser ESM bundle directly:

<script type="module">
  import { createSocketHub } from "https://cdn.example.com/socketio-hub.esm.min.js";

  const hub = createSocketHub({
    url: "https://realtime.example.com",
    namespace: "/chat",
    auth: { token: "access-token" },
  });

  await hub.connect();
</script>