Skip to content

Client

This documents the old v1 API. See Creating a Client for the current version.

The Zocket client (@zocket/client) is a typed WebSocket client that generates methods from your router type.

import { createZocketClient } from "@zocket/client";
import type { AppRouter } from "./server";
const client = createZocketClient<AppRouter>("ws://localhost:3000");
// Listen
client.on.chat.message((msg) => console.log(msg));
// Send
client.chat.post({ text: "Hi" });