Migrating from Pusher to PubSub Without Changing Your Code
Most realtime migrations are painful because the client library changes. This one isn't: PubSub speaks the Pusher protocol, so the same pusher-js you already ship keeps working. What changes is where it connects.
What actually changes
A standard Pusher setup points at Pusher's cluster. To move to PubSub you override the host:
import Pusher from "pusher-js";
const pusher = new Pusher(appKey, {
wsHost: "pubsub.nextmark.ae",
wsPort: 443,
forceTLS: true,
enabledTransports: ["ws", "wss"],
cluster: "mt1",
});
cluster is still required by pusher-js even though PubSub ignores it — leave it set to anything.
Authenticating private and presence channels
Private and presence channels need a signature. Point the library at your PubSub endpoints:
const pusher = new Pusher(appKey, {
wsHost: "pubsub.nextmark.ae",
wsPort: 443,
forceTLS: true,
cluster: "mt1",
userAuthentication: {
endpoint: "https://pubsub.nextmark.ae/api/authorize",
transport: "ajax",
headers: { "X-APP-Key": appKey },
},
channelAuthorization: {
endpoint: "https://pubsub.nextmark.ae/api/channels/authorize",
transport: "ajax",
headersProvider: () => ({
Authorization: `Bearer ${token}`,
"X-APP-Key": appKey,
}),
},
});
The authorize endpoint checks that the channel user is permitted to join that channel before signing, so access control stays on your side.
What stays identical
- Subscribing and binding.
pusher.subscribe("orders")andchannel.bind("updated", handler)are unchanged. - Channel types. Public, private and presence channels behave the same way.
- Server publishing. The HTTP trigger API is Pusher-compatible, so server SDKs and signed requests work as-is.
- Client events.
client-prefixed events on private channels still work where your plan allows them.
Verifying the switch
- Point a staging build at PubSub and watch the connection succeed in the browser console with
enableLogging: true. - Subscribe to a private channel and confirm the authorize endpoint returns a signature rather than a 403.
- Publish a test event from your backend and confirm it arrives.
If all three pass, the migration is done — there is no second phase.
Why teams in the Gulf do this
PubSub runs from Dubai. For users in the UAE and wider GCC that typically means sub-50ms delivery instead of 200ms or more spent routing to a European or US cluster, and it keeps data inside the UAE for applications with local residency requirements.