@getpubby/sdk
v0.2.0
Published
Pubby SDK for real-time messaging - a Pusher-compatible alternative
Maintainers
Readme
@getpubby/sdk
Official SDK for Pubby - a self-hosted, Pusher-compatible real-time messaging platform.
Installation
npm install @getpubby/sdkQuick Start
Client (Browser/Node.js)
import { Pubby } from "@getpubby/sdk";
const pubby = new Pubby("your-app-key", {
wsHost: "wss://your-socket-server.com",
authEndpoint: "/api/pubby/auth",
});
pubby.connect();
const channel = pubby.subscribe("my-channel");
channel.bind("my-event", (data) => {
console.log(data);
});Server (Node.js)
import { PubbyServer } from "@getpubby/sdk/server";
const pubby = new PubbyServer({
appId: "your-app-id",
key: "your-app-key",
secret: "your-app-secret",
});
// Trigger events
await pubby.trigger("my-channel", "my-event", { message: "Hello!" });
// Authenticate private channels
const auth = pubby.authenticatePrivateChannel(socketId, channelName);Channel Types
| Prefix | Type | Auth Required |
|--------|------|---------------|
| (none) | Public | No |
| private- | Private | Yes |
| presence- | Presence | Yes |
Documentation
License
MIT
