Docs

Realtime

Build realtime Niral apps with live WebSocket channels, server-side publishing and automatic reconnects. Authorize subscriptions with channel guards.

Live channels over framework-owned WebSockets — no socket.io.

<server>
export async function notify(text) {
  publish("alerts", { text })          // reaches every subscribed browser
  return true
}
</server>

<script>
  let feed = $state([])
  live("alerts", (msg) => feed = [...feed, msg])
</script>

live(channel, cb) subscribes (auto-reconnect included) and returns { send, close } — send fans out to the channel's other members. publish() works from any server language, jobs included.

Guarding channels

// hooks.js
export function liveAuth({ channel, user }) {
  if (channel.startsWith("private:")) return !!user
  return true
}

Denied joins get { type: "denied" } — and a crashing guard denies, never fails open.

> Running on more than one server? Turn on the cluster backplane > and publish() reaches subscribers on every node, not just the one that > ran the code.