forrealtime

Emitting Events

Send type-safe events to the default channel or a specific channel.

realtime.emit

Emit an event to the default channel:

await realtime.emit("notification.alert", "Hello");

await realtime.emit("chat.message", {
  text: "Hello world",
  user: "lasse",
});

The event name is "namespace.eventName" and the payload is validated against your Zod schema. TypeScript will infer the correct payload type from the event name.

On this page