Skip to Content
Commands

Commands

Commands are structured request/response messages—like RPC over WebSockets.

Clients send a named command with a payload, and the server responds. Use commands for things like auth, data fetching, or state updates.

Server: expose a command

server.exposeCommand("echo", async (ctx) => { return `echo: ${ctx.payload}`; });

Client: send a command

const response = await client.command("echo", "Hello!"); console.log(response); // "echo: Hello!"

Features

  • Built-in request/response
  • Async/await or sync API
  • Structured error handling
  • Middleware support (validation, auth, etc.)
  • Context includes payload, connection, and metadata

See Server SDK → Commands and Client SDK → Commands for full usage details.

Last updated on
© 2025