Docs/Events
Client Events
Send events directly from connected clients to other clients.
Client Events
Client events allow connected clients to send events directly to each other without going through your server. This is useful for low-latency interactions like typing indicators, cursor positions, or drawing on a shared canvas.
Requirements
- Enable Client Events in your app settings on the Socketo dashboard
- Client events must be sent on private or presence channels only
- Event names must start with
client-
Sending a Client Event
js
const channel = pusher.subscribe('private-chat-room')
channel.trigger('client-typing', {
is_typing: true,
})Receiving Client Events
js
channel.bind('client-typing', (data) => {
if (data.is_typing) {
showTypingIndicator()
}
})Presence Channels
On presence channels, the sender's user_id is sent as top-level event
metadata, not as part of the event data. pusher-js provides it as the second
callback argument:
js
channel.bind('client-message', (data, metadata) => {
console.log('From:', metadata.user_id)
console.log('Text:', data.text)
})Limitations
- Client events are not persisted — offline users will not receive them
- There is no guarantee of delivery — for critical messages, use server-triggered events
- Publish no more than 10 client events per second per connection. Events above this rate may be rejected.