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

channels_sdk

v1.0.19

Published

Channels SDK for communicating with the ChannelsServer

Readme

Channels JavaScript SDK

Check the main project here

If you want to connect to channels with your browser, then this is the right place for you! First get the code from here and check the authentication section for creating a JWT Token.

After getting the token, initialize the SDK with:

let channelsSDK = new ChannelsSDK({ 
    url: '://url:port', // Don't fill behind the ://
    appID: 'AppID',
    token: 'JWT Token',
    secure: false // If should be WSS or WS and HTTPS or HTTP
});

You need to keep the object around and using for almost everything


Getting your channels

To get the client channels you can retrieve the channels that are public or the ones that are private. To do that just use the following:

The package works in browser, it uses the native WebSocket, if you can replace it, then it can work on Node

channelsSDK.fetchPublicChannels().then(channels => { // Replace public with private for private channels
});

Listening for new channels and removed channels

You can know you when lost access to a channel for received with:

channelsSDK.setOnChannelAdded((channelID) => {
    // When you receive access to a channel
})

channelsSDK.setOnChannelRemoved((channelID) => {
    // When you lose access to a channel
})

Working with a Channel

The object Channel is the object you will use the most, with it you can subscribe, publish, get other clients presence and get events.

First, in order to get a instance you can get from getPublicChannels() or getPrivateChannels() or after you get the public or private channels you can get one with channelsSDK.getChannel("channelID");, if none is found it will return null!

Once you have a Channel you subscribe with:

channel.subscribe(() => {
    // Callback for when the subscribe is confirmed
})

And you can get events with:

channel.setOnMessage((event) => {
    // Callback for the event
});

For presences events you have:

// On initial status from the channel
channel.setOnInitialStatusUpdate(() => {
    // You can get the presence with
    channel.getPresencesStatus();
});

// When status changes
channel.setOnOnlineStatusUpdate((statusUpdate) => {
    // The user status that changed
});

// When a user is added to the channel
channel.setOnJoin((join) => {

});

// When a user is removed from the channel
channel.setOnLeave((leave) => {

});

Publishing

To publish messages is simple as:


    channel.publish("my_event", "my_payload_can_be_json", () => {
        // Published confirmation
    });

    // If you don't want the confirmation or don't want the event to be stored pass null on the callback
    channel.publish("my_event", "my_payload_can_be_json", null);

!> Important: If your event doesn't request a confirmation, Channels will consider that the event is not important to store on channels with persistence enabled!


Getting last events

For getting events it's as simple as:

You can check other types of getting events on the section Synchronization


// Get last X (5 in this case) events 
channel.fetchLastEvents(5).then(events => {
    console.log(events);
});

// Get X (5 in this case) since given timestamp (inclusive)
channel.fetchLastEventsSince(5, 1615570823).then(events => {
    console.log(events);
});

// Get events since timestamp (inclusive)
channel.fetchEventsSince(1615570823).then(events => {
    console.log(events);
});

// Since timestamp to Up to timestamp (inclusive)
channel.fetchEventsBetween(1615570823, 1615570823).then(events => {
    console.log(events);
});