Skip to content

Use case

Live application state

Most realtime is not chat. It is a job that finished, an order that shipped, a build that went red — state that changed while someone watched a stale copy.

private-job-7c4
  • private channels
  • events

How it works

  1. 01Subscribe to the resourceA private channel named for the thing on screen — a job, an order, a deployment.
  2. 02Publish transitionsEach committed state change is published with the new state.
  3. 03ConvergeClients apply it; one that missed a transition re-reads over HTTP on reconnect.

Worth knowing

Publish after the write commits. Publishing first shows a state the database will not confirm if the transaction rolls back.

In code

job.js
js
// Publish the transition after it is committed, not before.await job.markComplete()await pusher.trigger(`private-job-${job.id}`, 'state-changed', {  state: 'complete',  finished_at: job.finishedAt.toISOString(),})

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

Other things people build

All use cases
presence-room-42

Realtime chat

Rooms, membership and typing indicators on presence channels.

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