Getting Started
First Connection
Connect with a Pusher-compatible client and trigger your first event.
1) Connect a Client
sockudo accepts standard Pusher WebSocket clients.
app.ts
import Pusher from "pusher-js";
const pusher = new Pusher("app-key", {
cluster: "mt1", // required by many clients, not used by Sockudo host routing
wsHost: "127.0.0.1",
wsPort: 6001,
forceTLS: false,
enabledTransports: ["ws"],
});
const channel = pusher.subscribe("my-channel");
channel.bind("my-event", (payload: unknown) => {
console.log("received:", payload);
});
2) Trigger an Event (Backend SDK)
Use a backend Pusher-compatible server SDK for signed publish requests.
trigger.ts
import Pusher from "pusher";
const pusher = new Pusher({
appId: "app-id",
key: "app-key",
secret: "app-secret",
cluster: "mt1",
host: "127.0.0.1",
port: 6001,
useTLS: false,
});
await pusher.trigger("my-channel", "my-event", {
message: "hello from Sockudo",
sentAt: Date.now(),
});
3) Verify Realtime Flow
When the backend trigger runs, your subscribed client should receive my-event immediately.
Using @sockudo/client Instead
For core behavior, either client works:
client.ts
import Pusher from "@sockudo/client";
Use @sockudo/client if you need advanced Sockudo extensions like tag filters or delta decode.
Next
- Private and presence auth: Authentication
- Migration details: Migration