All documentation
WebSockets

Presence Event Types

Understand the websocket presence event types returned by PulseGrid.

JavaScript

Overview

PulseGrid websocket connections can emit several presence-related event types. Common types: - presence_snapshot - presence_joined - presence_left - presence_count - presence_check_result

Setup

Listen for messages in your websocket callback and inspect payload.type.

Code example

Presence Event Types
const chat = await pulsegrid.channel("demo-channel").connect({
  clientToken: token,
  onMessage: (payload) => {
    if (payload.type === "presence_joined") {
      console.log("Someone joined:", payload.member);
    }

    if (payload.type === "presence_left") {
      console.log("Someone left:", payload.member);
    }

    if (payload.type === "presence_count") {
      console.log("Online count:", payload.online_count);
    }
  },
});

Notes

This makes it easy to update live UI state without polling constantly.