Presence channel

A presence channel is a Pusher-protocol channel type that maintains a server-side roster of subscribed members and emits join and leave events as that roster changes. Channel names use the presence- prefix.

Why it matters

Presence channels are the right primitive for any feature that answers "who else is here." Document collaboration uses them for the avatars in the header. Live chat uses them for the online list. Multiplayer experiences use them for the lobby roster. The service holds the canonical roster, so clients do not have to reconcile state from a thin event stream.

Presence is also one of the most fan-out-heavy channel types in practice. Every member.added and member.removed event broadcasts to every other subscriber. A channel with 200 members produces 200 deliveries per join and 200 per leave. This makes the per-broadcast versus per-delivered-copy billing distinction (see fan-out tax) particularly load-bearing on presence-heavy workloads.

How it works

A client subscribes to a presence channel the same way it subscribes to a private channel, with one addition: the channel auth callback returns channel_data (a JSON object containing user_id and optional user_info) alongside the auth signature. The service uses user_id as the canonical identity for the member in the roster.

After a successful subscribe, the client receives three internal events in order:

  • pusher_internal:subscription_succeeded with the full current member list.
  • pusher_internal:member_added for every subsequent join, fanned out to all members.
  • pusher_internal:member_removed for every leave.

A typical Laravel server-side auth response looks like:

{
    "auth": "app-key:hmac-signature",
    "channel_data": "{\"user_id\":\"user-42\",\"user_info\":{\"name\":\"Ada\"}}"
}

The user_id is the deduplication key. If the same user opens two tabs, the service emits member.added once for the first tab and ignores the duplicate from the second. member.removed fires when the last connection for that user_id drops.

Related terms

  • Private channel is the auth-gated cousin without the roster.
  • Channel auth is the handshake that authorizes presence subscriptions.
  • Fan-out is what every member.added and member.removed event triggers.

See also

What is a presence channel?
A presence channel is a Pusher-protocol channel type that maintains a server-side roster of subscribed members and emits member.added and member.removed events as users join and leave. Channel names start with the presence- prefix.
How is a presence channel different from a private channel?
Both require channel auth. A private channel only enforces who can join. A presence channel additionally surfaces who else is in the channel right now and notifies subscribers when membership changes.
What is a presence channel used for?
Anything that needs a live roster: who is viewing this document, who is in this room, who is online for chat, who is editing this row. The roster is maintained by the service so every subscriber sees the same membership.