Client SDK

@irtio/client is the browser-side API. One call gives you a room handle with reactive state, typed RPCs, presence, and connection status.

joinRoom

function joinRoom<S>(schema: S, options?: JoinOptions): Promise<Room<S>>;
OptionTypeDefaultMeaning
idstringrandomjoin/create a specific room
envstring'production'which deployed environment
metaobject{}data passed to the server’s onJoin
predictstring[][]entities to client-side predict

The room handle

interface Room<S> {
  me: string;                      // your clientId
  state: State<S>;                 // reactive, writable where you own it
  rpc: Rpc<S>;                     // typed server calls
  presence: Presence;              // ephemeral per-client data
  subscribe(fn: (s: State<S>) => void): () => void;
  onStatus(fn: (s: Status) => void): () => void;
  leave(): void;
}

Reading & writing state

room.subscribe((s) => render(s));         // called on every visible change
room.state.players[room.me].x += dx;      // write what you own

Writing an entity you don’t own is a no-op locally and rejected server-side.

RPCs & presence

const res = await room.rpc.play({ card });   // typed args + return
room.presence.set({ typing: true });
room.presence.subscribe((all) => render(all));

Status

'connecting' | 'live' | 'reconnecting' | 'closed' — drive your connection UI from onStatus.

Next steps

Placeholder reference.