<!-- PkgPulse AI-readable guide source -->
<!-- Canonical: https://www.pkgpulse.com/guides/ably-vs-pusher-channels -->
<!-- Raw Markdown: https://www.pkgpulse.com/guides/ably-vs-pusher-channels/raw.md -->
<!-- Source path: content/guides/ably-vs-pusher-channels.mdx -->

---
title: "Private Channels and Presence After Reconnect"
description: "Compare Ably and Pusher Channels for private room access, multi-tab presence, and reconnects. Learn when to replace a roster and when to reload missed data."
date: "2026-12-04"
author: "PkgPulse Team"
tags: ["realtime", "pubsub", "channel-authorization", "presence"]
tileSubjects:
  - slug: ably
    name: Ably
  - slug: pusher
    name: Pusher Channels
---

<!-- pipeline:source pp3-src-device-npm -->
<!-- pipeline:source pp3-src-legacy-npm -->
<!-- pipeline:source pp3-src-device-release -->
<!-- pipeline:source pp3-src-device-migration -->
<!-- pipeline:source pp3-src-device-types -->
<!-- pipeline:source pp3-src-ably-token -->
<!-- pipeline:source pp3-src-ably-jwt -->
<!-- pipeline:source pp3-src-ably-capability -->
<!-- pipeline:source pp3-src-ably-presence -->
<!-- pipeline:source pp3-src-ably-presence-api -->
<!-- pipeline:source pp3-src-ably-channel-state -->
<!-- pipeline:source pp3-src-ably-recovery -->
<!-- pipeline:source pp3-src-pusher-browser-npm -->
<!-- pipeline:source pp3-src-pusher-browser-release -->
<!-- pipeline:source pp3-src-pusher-server-npm -->
<!-- pipeline:source pp3-src-pusher-server-release -->
<!-- pipeline:source pp3-src-pusher-auth-endpoint -->
<!-- pipeline:source pp3-src-pusher-signatures -->
<!-- pipeline:source pp3-src-pusher-auth-types -->
<!-- pipeline:source pp3-src-pusher-server-types -->
<!-- pipeline:source pp3-src-pusher-presence-docs -->
<!-- pipeline:source pp3-src-pusher-presence-types -->
<!-- pipeline:source pp3-src-pusher-connection -->
<!-- pipeline:source pp3-src-pusher-resubscribe -->
<!-- pipeline:source pp3-src-pusher-history -->
<!-- pipeline:source pp3-src-loopback -->

<!-- pipeline:claim pp3-choice -->

Keep **Pusher Channels** if your app already authorizes room subscriptions and needs a list of signed-in users. Replace that list on every successful presence subscription. Choose **Ably** if you need permissions per channel operation, presence per connection, or channel resume with a signal that tells you when message continuity was lost. With either client, plan how to reload durable room data when you cannot account for the events the client missed.

## Quick decision

<!-- pipeline:claim pp3-ably-auth -->
<!-- pipeline:claim pp3-pusher-auth -->
<!-- pipeline:claim pp3-presence-identity -->
<!-- pipeline:claim pp3-reconnect -->

| Requirement | Ably | Pusher Channels |
| --- | --- | --- |
| Restrict who can join the room | Issue a token scoped to the channel and allowed operations. | Sign the requested `private-` or `presence-` subscription for the current socket after checking room access. |
| Show who's here | Explicitly enter presence. Read a synchronized roster keyed by `clientId` and `connectionId`. | Subscribe to a `presence-` channel. Read the member list keyed by user ID. |
| Keep a user visible when they close one of several tabs | Group the remaining connections under the same `clientId`. | The service reports when the user's first connection joins and last connection leaves. |
| Rebuild after a disconnect | Check channel continuity and use `presence.get()` for the synchronized roster. | Use the members payload from the next `pusher:subscription_succeeded` as a replacement roster. |

For a wider choice between hosted pub/sub and running a socket server, see the [realtime library comparison](/guides/best-realtime-libraries-2026) and the [Node.js WebSocket library guide](/guides/best-websocket-libraries-nodejs-2026).

## Authorize the same private room

Start both implementations with the same server-side check. Read the signed-in identity from your session, resolve the requested room to its canonical channel name, and check that the user still has access. Use the session account ID as the presence identity. Treat the room name and any identity the browser sends as input to validate.

<!-- pipeline:claim pp3-sdk-packages -->

### Ably issues an identity and a capability grant

The current browser client uses `createClient()` from `@ably/pubsub-device`. Code that already imports `ably` uses the earlier package and has a separate SDK migration to plan. The fixture below uses the current device package. [Ably SDK migration guide](https://raw.githubusercontent.com/ably/ably-pubsub-js/3.3.0/docs/migration-guides/v3/lib.md).

<!-- pipeline:claim pp3-ably-auth -->

Configure `authUrl` or `authCallback` so the device SDK can fetch and renew a token. For a member who can read room messages and appear in the roster, sign a JWT with the session account ID in `x-ably-clientId`. Scope `x-ably-capability` to the exact room, such as `room:orchid`. Grant `message-subscribe` to receive messages, `presence-subscribe` to read the roster, and `presence` to enter, update or leave. A client that only watches the roster needs no `presence` capability. Keep the signing key on the server and recheck the session and room policy each time you issue a token. [Token authentication](https://ably.com/docs/auth/token), [JWT claims](https://ably.com/docs/auth/token/jwt#jwt-claims), [capabilities](https://ably.com/docs/auth/capabilities#capability-operations).

### Pusher Channels signs a subscription for the current socket

<!-- pipeline:claim pp3-pusher-auth -->

Pass the public app key to `pusher-js` and set `channelAuthorization.endpoint`. The AJAX request sends `socket_id` and `channel_name` to your server. For events without a roster, authorize a name such as `private-room-orchid`. For a room with events and a roster, use `presence-room-orchid`. That presence channel already requires authorization. [Channel authorization](https://pusher.com/docs/channels/server_api/authorizing-users/), [presence channels](https://pusher.com/docs/channels/using_channels/presence-channels/).

On the server, the `pusher` package's `authorizeChannel()` signs the socket ID and channel name. In the presence flow used here, supply `user_id` from the session as the third argument's user data. The response also includes signed `channel_data` for that presence subscription. The separate Pusher user authentication flow can also provide the presence identity. Keep the app secret on the server, return a denial for unauthorized rooms and show `pusher:subscription_error` separately from an empty room. [Authorization signatures](https://pusher.com/docs/channels/library_auth_reference/auth-signatures/), [subscription errors](https://pusher.com/docs/channels/using_channels/connection/).

## Restore presence after reconnect

<!-- pipeline:claim pp3-presence-identity -->
<!-- pipeline:claim pp3-reconnect -->
<!-- pipeline:claim pp3-reconcile -->

**Ably.** Subscribe to presence changes, enter when the user should appear, and take the initial roster from `presence.get()`. The default waits for the SDK's presence set to synchronize. Keep members by the pair of `clientId` and `connectionId`, then group by `clientId` if the UI shows people. Leaving on one connection removes that connection from the group. [Presence API](https://ably.com/docs/pub-sub/api/javascript/realtime/realtime-presence), [presence identity](https://ably.com/docs/presence-occupancy/presence).

The Ably SDK attempts to resume after a network drop. Watch the channel's `attached` and `update` events. With a prior attachment, `resumed: false` means message continuity was lost. On a fresh connection, the first attachment has `resumed: false`. Load the initial room state then. After a loss of continuity, use a synchronized presence read and reload any durable data the room needs. Ably can re-enter members previously entered by the same SDK instance when it resynchronizes its presence set. A fresh instance recovering a previous connection needs to enter explicitly. [Channel states](https://ably.com/docs/channels/states), [presence recovery](https://ably.com/docs/presence-occupancy/presence#handle-unstable-connections-and-failures).

**Pusher Channels.** Mark the displayed list stale when the connection drops. The client resubscribes to its channels when it reconnects. Wait for `pusher:subscription_succeeded` on the presence channel and copy `members.each()` into a fresh map keyed by member ID. Apply `pusher:member_added` and `pusher:member_removed` to that map. Replacing the entire map removes users who left during the gap. The connection's `connected` event can arrive before the room is authorized and ready. [Presence events](https://pusher.com/docs/channels/using_channels/presence-channels/), [client resubscription code](https://raw.githubusercontent.com/pusher/pusher-js/v8.6.0/src/core/pusher.ts).

Keep the member list separate from chat messages, acknowledgments or document changes. For ordinary Pusher Channels events, a new subscription gives you live delivery going forward. Use your application endpoint for missed durable events. Ably resume can preserve message continuity, but a failed resume calls for your application's recovery path. Fetch a snapshot with a server revision after subscribing, queue events while it loads, and apply newer events from the same room. Ignore a late snapshot from an older room or connection attempt. [Pusher's message history example](https://pusher.com/blog/how-to-add-message-history-to-your-pusher-apps/), [Ably connection recovery](https://ably.com/docs/connect/states).

## Methodology

<!-- pipeline:claim pp3-sdk-packages -->
<!-- pipeline:claim pp3-fixture-local -->

A loopback fixture ran `@ably/pubsub-device` **3.3.0** and `pusher-js` **8.6.0** through their Node-targeted builds on Bun. The Pusher authorization endpoint used the `pusher` **5.3.4** server signer. The fixture used synthetic credentials and scripted HTTP and WebSocket responses.

| Scenario | Local observation |
| --- | --- |
| Attempt to join an unauthorized room | The Ably fixture's token endpoint denied the other room, and the device client rejected its attach when the mock returned a channel authorization error. Pusher Channels surfaced a subscription error after the auth endpoint denied the other room. |
| Remove a connection for a user with another open tab | The Ably client returned both connections for Sam initially and still returned Sam's remaining connection after the scripted leave. Pusher's first-join and last-leave behavior is documented service behavior. |
| Disconnect, then replace a stale member | The Ably client requested resume and handled a resumed attachment. A later simulated continuity loss triggered an update and the synchronized roster replaced Sam with Lee. Pusher reauthorized with the new socket ID, resubscribed, and the new members snapshot replaced Sam with Lee. |

Repeat these scenarios against your hosted app before switching. Open two tabs under the same account and a separate observer. Close one tab and check that the observer still sees the user. Put the observer offline, have a different user join and the remaining tab leave, then bring the observer back and compare its roster with a fresh observer. In Ably, exercise a reconnect that resumes and one that reports lost continuity. In Pusher Channels, verify authorization runs again and wait for the new room snapshot. Check that an unauthorized room remains inaccessible in both cases. The loopback run verified client handling with scripted inputs. Hosted token enforcement, timing, message replay and first-join or last-leave behavior were outside that run.

If maintaining the room's document state is the larger job, compare [Liveblocks, PartyKit and Hocuspocus](/guides/liveblocks-vs-partykit-vs-hocuspocus-realtime-2026) before building the state layer on pub/sub.
