All documentation
WebSockets

Presence in JavaScript

Check live online count, full presence snapshot, and whether a specific identifier is online.

JavaScript

Overview

PulseGrid presence lets you track who is online in a channel, how many are online, and when people join or leave.

Setup

Use: - presence() - onlineCount() - isOnline(identifierId) Over websocket you can also request: - requestPresenceSnapshot() - checkPresence(identifierId)

Code example

Presence in JavaScript
const channel = pulsegrid.channel("demo-channel");

console.log(await channel.presence());
console.log(await channel.onlineCount());
console.log(await channel.isOnline("user_123"));

const chat = await channel.connect({
  clientToken: token,
  onMessage: (payload) => console.log(payload),
});

chat.requestPresenceSnapshot();
chat.checkPresence("user_123");

Notes

Useful for chat apps, collaboration tools, support systems, and anything that needs join/leave or online/offline tracking.