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

@xhub-ui/chat-lite

v0.1.1

Published

Lightweight 1-on-1 chat SDK for XHub - zero dependencies on @xhub-chat/*

Readme

@xhub-ui/chat-lite

Lightweight 1-on-1 chat SDK for XHub. This package is intentionally small: it uses native fetch, Centrifuge for realtime, and does not depend on @xhub-chat/core or @xhub-chat/nextjs.

Install

pnpm add @xhub-ui/chat-lite

Usage

Basic Usage

import { ChatLiteClient } from '@xhub-ui/chat-lite';

const client = new ChatLiteClient({
  baseUrl: 'https://gw-messages.blocktrend.xyz',
  accessToken: 'eyJhbGciOi...',
  realtime: {
    url: 'wss://centrifugo-sb-message.blocktrend.xyz/connection/websocket',
  },
});

client.on('connected', () => {
  console.log('Connected');
});

client.on('message', (message) => {
  console.log('New message', message);
});

client.on('error', (error) => {
  console.error(error.code, error.message);
});

await client.connect();

const rooms = await client.getRooms();
await client.sendMessage(rooms[0].id, 'Hello!');

const history = await client.getMessages(rooms[0].id, { limit: 20 });
console.log(history.messages);

const newRoom = await client.createRoom('user-002');
console.log(newRoom);

client.updateToken('new-access-token');
client.disconnect();

Global Configuration

Set global config once, reuse across multiple client instances:

import { setGlobalConfig, ChatLiteClient } from '@xhub-ui/chat-lite';

// Set global defaults
setGlobalConfig({
  baseUrl: 'https://gw-messages.blocktrend.xyz',
  accessToken: 'eyJhbGciOi...',
  realtime: {
    url: 'wss://centrifugo-sb-message.blocktrend.xyz/connection/websocket',
  },
});

// Create clients without passing a userId
const client1 = new ChatLiteClient({
  baseUrl: 'https://gw-messages.blocktrend.xyz',
  accessToken: 'eyJhbGciOi...',
});
const client2 = new ChatLiteClient({
  baseUrl: 'https://gw-messages.blocktrend.xyz',
  accessToken: 'eyJhbGciOi...',
});

// Instance options override global config
const client3 = new ChatLiteClient({
  baseUrl: 'https://api-dev.xhub.vn', // Override global baseUrl
});

Demo

A standalone demo application is available at packages/chat-lite-demo. Run it with:

cd packages/chat-lite-demo
pnpm install
pnpm dev

The demo runs on port 3001 and demonstrates all chat-lite features including room management, messaging, and realtime updates.

API

new ChatLiteClient(options)

Required options:

  • baseUrl: XHub API base URL. The lite client targets /api/v1 endpoints.
  • accessToken: bearer token used for HTTP and, by default, realtime auth.

Optional options:

  • userId: current user ID, only needed when consumers want user:{userId} as a default realtime channel or local outgoing-message fallback metadata.
  • realtime.url: Centrifuge websocket endpoint.
  • realtime.initialToken: token passed to Centrifuge on construction. Defaults to accessToken.
  • realtime.defaultChannels: defaults to ['online:index'], or ['online:index', 'user:{userId}'] when userId is provided.
  • realtime.autoStart: defaults to true.
  • useAuthorizationHeader: defaults to true.
  • fetchFn: custom fetch implementation.
  • logLevel: debug, info, warn, error, or silent.

Methods

  • connect(): Promise<void>
  • disconnect(): void
  • sendMessage(roomId, body): Promise<Message>
  • getMessages(roomId, options?): Promise<MessagesResponse>
  • createRoom(withUserId): Promise<Room> sends participants: [withUserId].
  • getRooms(): Promise<Room[]>
  • getRealtime(): CentrifugeLiteRealtime | undefined
  • updateToken(token): void

Events

  • connected
  • disconnected
  • reconnecting
  • message
  • error
  • realtime.connected
  • realtime.disconnected
  • realtime.reconnecting
  • realtime.error
  • realtime.message.new
  • realtime.room.updated
  • realtime.presence