Docs/Listening to Events
Docs/Events

Listening to Events

How to bind to and handle events on channels.

Listening to Events

Events are messages sent over channels. When your server triggers an event, all clients subscribed to that channel receive it in real time.

Binding to Events

js
const channel = pusher.subscribe('my-channel')

channel.bind('new-message', (data) => {
  console.log('Event received:', data)
})

Global Binding

Listen to all events across all channels:

js
pusher.bind_global((eventName, data) => {
  console.log(eventName, data)
})

SDK And Protocol Events

The SDK exposes the following events. Some are SDK-level names mapped from pusher_internal:* wire events:

EventDescription
pusher:subscription_succeededSDK event after a successful subscription
pusher:subscription_errorSDK event when channel authorization fails; not a wire event sent by Socketo
pusher:member_addedSDK event mapped from pusher_internal:member_added
pusher:member_removedSDK event mapped from pusher_internal:member_removed
pusher:errorWire-level protocol error, usually handled globally
pusher:signin_successWire-level successful user authentication event
js
channel.bind('pusher:subscription_error', (data) => {
  console.error('Authorization failed:', data.error)
})

pusher.bind('pusher:error', (error) => {
  console.error('Protocol error:', error.code, error.message)
})

For full details on event binding, unbinding, and advanced patterns, see the Pusher SDK docs.