Skip to content
Docs/Presence Channels
Docs/Channels

Presence Channels

Presence channel specification, member awareness protocol, and roster limits.

Specification

Presence channels build on private channels by tracking and synchronizing online participant rosters. All presence channel names must begin with the presence- prefix (e.g. presence-chat-room).

Subscriptions require an authorization payload containing both an HMAC signature and serialized user identity (channel_data).

Authorization Token Specification

The backend authorizes subscriptions and supplies member identity:

plaintext
String to sign: ${socket_id}:${channel_name}:${channel_data}
Signature:      HMAC-SHA256(secret, string_to_sign)
Payload:        { "auth": "${app_key}:${signature}", "channel_data": "${channel_data}" }

Channel Data JSON Schema

channel_data must be a serialized JSON string containing:

json
{
  "user_id": "user_42",
  "user_info": {
    "name": "Alice",
    "role": "admin"
  }
}
PropertyTypeRequiredDescription
user_idstringYesUnique user identifier (max 128 characters).
user_infoobjectNoArbitrary member metadata (max 1 KiB total size).

Presence Protocol Events

Wire FrameClient SDK EventTrigger ConditionPayload Properties
pusher_internal:subscription_succeededpusher:subscription_succeededInitial channel subscription succeeds{ presence: { ids, hash, count } }
pusher_internal:member_addedpusher:member_addedNew member joins channel{ user_id, user_info }
pusher_internal:member_removedpusher:member_removedMember leaves or disconnects{ user_id }

Multi-Tab De-duplication

If a single user_id establishes multiple concurrent connections to the same presence channel:

  • The member count increments only once.
  • member_added broadcasts only when the user's first socket joins.
  • member_removed broadcasts only after the user's final socket closes.

Presence Limits

ResourceThresholdBehavior When Exceeded
Max Members per Channel100 unique user IDsSubscription rejected with wire error 4300
Max user_id Length128 charactersSubscription rejected with wire error 4300
Max User Object Size1 KiB (1,024 bytes)Subscription rejected with wire error 4300

Client SDK Reference

ts
const presenceChannel = pusher.subscribe('presence-chat-room')

// Initial online members roster
presenceChannel.bind('pusher:subscription_succeeded', (members: any) => {
  console.log('Online count:', members.count)
  members.each((member: { id: string; info: Record<string, any> }) => {
    console.log('Member:', member.id, member.info)
  })
})

// Member joined
presenceChannel.bind('pusher:member_added', (member: { id: string; info: Record<string, any> }) => {
  console.log('Joined:', member.id)
})

// Member left
presenceChannel.bind('pusher:member_removed', (member: { id: string }) => {
  console.log('Left:', member.id)
})