@playhub/client
v0.1.1
Published
Multiplayer SDK for vibe-coded web games: rooms, room codes, ready-up, synchronized start and WebRTC peer-to-peer links.
Maintainers
Readme
@playhub/client
The multiplayer SDK for your vibe-coded web games. Browser side of playhub: connect to a playhub hub, list, create and join rooms, ready up, start together, and talk to the other players over WebRTC data channels.
npm install @playhub/clientimport { HubClient } from '@playhub/client';
const hub = new HubClient({
url: 'wss://play.example.com/v1/lobby',
game: 'my-game',
player: () => ({ id: myStablePlayerId, name: 'Ada' }),
});
const room = await hub.create({ name: 'Fun', visibility: 'public', settings: {}, maxPlayers: 4 });HubClient: the signaling connection. Reconnects with backoff and resumes your seat by player id.LiveRoom(hub.room): members, readiness, the synchronized start (tick()events) and the peer links:sendToHost,broadcast,sendTo,onHostMessage,onClientMessage.PeerLink: one WebRTC data channel. Pass your owncreateLinkto swap it out (tests do).SignalingTransport: howHubClientreaches the hub.WebSocketTransportis the default (fromurl); passtransportinstead to use your own back end.
See the repository README for the full flow. MIT licensed.
