This page covers the current version of Realtime. For the legacy Realtime Event function, see Realtime Functions (Legacy).
realtime.publish injects a server-authored event onto a channel from anywhere in Xano — a query, a custom function, or a scheduled task. The clients on that channel receive it over their existing connection, with no polling and no client-side request.
Publish in the visual editor
In a function stack, add Realtime Publish from APIs & Lambdas, or search for it by name. It is the visual editor equivalent ofrealtime.publish.
Realtime Server and Channel accept constants, variables, and expressions. Autocomplete offers workspace server names and channel templates as suggestions; it does not restrict values to that list. Resolve a template such as
rooms/{room_id} to rooms/42 before publishing. A channel path belongs to a particular server, so supply both fields. If suggestions fail to load, you can still enter the values directly.
Message does not invoke a message handler. Publishing with message = "send" delivers your Data as-is with type: "send"; it does not run the send handler’s input validation, function stack, or per-message authentication. Authorize the calling API or stack before publishing. The optional Authentication fields attach identity metadata only; they do not validate credentials or grant access.
Availability and version choice
Realtime Publish requires Realtime V2 support on the instance. In the picker category and search results, it is greyed out with an explanation when V2 is unavailable. An empty autocomplete list is a separate issue and does not mean V2 is disabled. Realtime Event (v1) remains available for legacy connections. Its XanoScript statement isapi.realtime_event. It cannot reach V2 subscribers and can complete without an error while delivering nothing to them. Do not substitute it when Realtime Publish is unavailable; check V2 availability on the instance instead.
realtime.publish
realtime.publish returns nothing, so it takes no as $variable binding.
Example
XanoScript
realtime.get_session
realtime.get_session reads the current realtime execution context; it is not needed to publish from an ordinary API or function. It takes no required arguments and requires an as $variable binding. See the message handler example for use inside a realtime message.
Where you can publish from
Patterns
Notification and dashboard channels
Set the channel’spublish.who to nobody. Clients join and listen but can never send, and every update on the channel comes from a stack you control. This is the cleanest shape for notifications, status feeds, and live dashboards.
Broadcast after a database write
Write the record first, then publish. Persisting before publishing means a client that joins after the fact — and reads the channel transcript or queries your table — sees the same thing as one that was connected the whole time.Progress and streaming
A long-running task can publish incremental updates on a channel keyed to the job, so the client sees progress rather than a spinner. The same pattern streams an LLM or agent response back over the connection as it’s produced.Publishing vs. a message handler
Both put data on a channel, but they start from different places:
Use a message when the client is asking for something. Use
realtime.publish when Xano has something to tell the client.
realtime.publish is not api.realtime_event. The Realtime Event function (api.realtime_event, shown as Realtime Event (v1) in the statement picker) belongs to Realtime (Legacy). They are different statements targeting different systems — a legacy channel can’t be reached with realtime.publish, and a v2 channel can’t be reached with api.realtime_event.Verify delivery
Connect two V2 clients to the same server and resolved channel, and wait for both join acknowledgements. Run the publishing stack and confirm both receive anaction: "message" frame with type: "announcement" and the supplied payload. A successful stack or HTTP response alone does not prove delivery. See Connecting a Client.
Next steps
Messages
Client-invoked handlers, and delivery targeting.
Servers & Channels
Channel path templates, settings, and transcript.