Are you an LLM? You can read better optimized documentation at /documentation/api/client/functions/createClient.md for this page in Markdown format
ws-asyncapi API / client / createClient
Function: createClient()
createClient<
C>(url,path,options?):WsClient<InferClient<C>>
Defined in: .api-entries/client/index.d.ts:330
Codegen-free typed client. Infers the full client surface (events, commands, RPCs, typed errors, query/headers) directly from a server Channel type — no CLI step, no generated file, no global declare module. Same runtime as websocketAsyncAPI.
ts
import type { chat } from "./server"; // the Channel value's type
import { createClient } from "@ws-asyncapi/client";
const client = createClient<typeof chat>("ws://localhost:3000", "/chat/1");
client.onEvent("message", (m) => m.text); // typed
const { items } = await client.request("history", { limit: 50 }); // typedType Parameters
C
C extends AnyChannel
Parameters
url
string
path
InferClient<C>["address"]
options?
WebsocketAsyncAPIOptions<AsRecord<InferClient<C>["query"]>, AsRecord<InferClient<C>["headers"]>>
Returns
WsClient<InferClient<C>>