send()
send(args: { type: "broadcast" | "presence" | "postgres_changes"; event: string; payload?: any }, opts?: { timeout?: number }): Promise<"ok" | "timed out" | "error">
Send a message on the channel. Broadcast falls back to HTTP when the WebSocket is not ready (this fallback will be removed; use httpSend() instead).
Parameters
args
object
opts
{ timeout?: number }
Timeout and other options
Response
Promise
"ok" | "timed out" | "error"
Send result
Example
channel.subscribe(async (status) => {
if (status !== "SUBSCRIBED") return;
await channel.send({
type: "broadcast",
event: "cursor-pos",
payload: { x: 12, y: 40 },
});
});