Skip to content

Use case

Realtime chat

A chat room is a presence channel. Membership comes from the channel, not a table you keep in sync. Messages are events; typing indicators never touch your server.

presence-room-42
  • presence channels
  • events
  • client events
  • webhooks

How it works

  1. 01AuthoriseYour server decides whether this user may join, and returns their member id.
  2. 02Render membershipThe subscription returns the member list; join and leave events keep it current.
  3. 03Send messagesPublished as events, after your server has persisted and authorised them.
  4. 04Typing indicatorsClient events, sent between subscribers — ephemeral, so no round trip.

Worth knowing

History is your database's job, not the channel's. A client that joins gets what happens next — load the backlog over HTTP.

In code

room.js
js
const room = pusher.subscribe('presence-room-42')room.bind('pusher:subscription_succeeded', (members) => {  renderMemberList(members)})room.bind('pusher:member_added', (m) => addMember(m))room.bind('pusher:member_removed', (m) => removeMember(m))room.bind('message', (msg) => appendMessage(msg))// Ephemeral, straight between subscribers.input.oninput = () => room.trigger('client-typing', { at: Date.now() })

Written with the official Pusher libraries, unmodified — there is no PushCaster package to install. Full documentation

Other things people build

All use cases
private-user-1e9

Notifications

One server event, delivered to every surface a user has open.

private-metrics

Live dashboards

Push metrics as they change instead of polling for them.

Create an application and build it.

Support