Client events

Subscribers of private and presence channels can send events straight to the channel's other subscribers, without going through your backend: typing indicators, cursors, reactions.

Enable them

Client events are off by default. Switch them on per app in the dashboard, under Apps & keys. The change applies to connections opened afterwards.

Send and receive

client.ts
const room = thunderclap.subscribe("private-room-42");

room.trigger("client-typing", { user: "ada" });

room.bind("client-typing", (data, meta) => {
  showTyping(data.user, meta.userId); // userId is set on presence channels
});
  • Names must start with client-.
  • The channel must be private or presence, and subscribed.
  • trigger returns false when the event can't be sent (not subscribed, public channel, invalid name).
  • The sender doesn't receive its own event.

Rules

RuleValue
ChannelsPrivate and presence only
Rate10 events per second per connection
SizeUp to 10 KB of data
Sequence numbersNone: a missed client event is never reported as a gap
Cache channelsClient events are never cached

Refused events are reported as an error on the channel with code 4306.

Your backend can receive every client event through the client_event webhook.