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:
| Event | Description |
|---|---|
pusher:subscription_succeeded | SDK event after a successful subscription |
pusher:subscription_error | SDK event when channel authorization fails; not a wire event sent by Socketo |
pusher:member_added | SDK event mapped from pusher_internal:member_added |
pusher:member_removed | SDK event mapped from pusher_internal:member_removed |
pusher:error | Wire-level protocol error, usually handled globally |
pusher:signin_success | Wire-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.