Real-time channels
Define channels with typed callbacks and pattern-matched topics. Join, leave, and broadcast with compile-time guarantees on socket state: the Gleam compiler holds you to your own assigns type.
Channels guide →Type-safe real-time channels and presence for Gleam, targeting the Erlang (BEAM) runtime.
import berylimport beryl/presence
// Track who's online and broadcast every change to the room —// Phoenix-compatible presence diffs, backed by a CRDT.let config = presence.Config( pubsub: Some(ps), replica: "node-1", broadcast_interval_ms: 1500, on_diff: Some(fn(diff) { beryl.broadcast_presence_diff(channels, "room:lobby", diff) }), )
// …then, inside your channel's join callback:let _ref = presence.track(p, "room:lobby", "user:alice", socket.id(socket), meta)
// ps, channels, p and meta come from your app — see the Presence guide.Add beryl and its BEAM dependencies to your Gleam project. beryl installs as a git dependency, which needs Gleam 1.18+.
Installation guide →Wire up server callbacks, the WebSocket transport, and a Phoenix JS client, end to end, in one sitting.
Open the Quick Start →Browse complete, runnable examples, then go deeper in the guides or the API reference.
View examples →Define channels with typed callbacks and pattern-matched topics. Join, leave, and broadcast with compile-time guarantees on socket state: the Gleam compiler holds you to your own assigns type.
Channels guide →Know who's online with a CRDT-backed presence system. An add-wins observed-remove set resolves joins and leaves automatically across distributed nodes.
Presence guide →Distributed publish/subscribe powered by Erlang's pg process groups. Works across cluster nodes with zero configuration.
A JSON array wire format compatible with Phoenix client libraries, served over WebSockets by beryl_mist or beryl_ewe.