Skip to content
  • Channels
  • Reference
  • Channel Stats

Channel Stats

We provide functionality to get statistics about certain channels, such as how many users are currently connected to them.

💡

This reference assumes you have already set up the Hop server-side SDK.

Get Stats

The following function will return the following type:

type Stats = {
	// How many clients are connected to this channel
	online_count: number;
};
// Import your Hop SDK instance
import {hop} from '.';
 
const channelId = 'channel_xxx'; // the channel we want to get statistics for
 
const stats = await hop.channels.getStats(channelId);
/*
 * - stats = {
 * -     "online_count": 0
 * - }
 */
Last updated on September 21, 2022