Configuration

Rally reads its configuration from gleam.toml under [[tools.rally.clients]]. Each entry describes one browser app namespace.

[[tools.rally.clients]]
namespace = "public"
route_root = "/"
protocol = "etf"

Generated server files

When codegen runs, Rally writes the following files into src/generated/<namespace>/:

FilePurpose
router.gleamRoute type, parser, path builder, and href
page_dispatch.gleamPer-route page init, update, and view dispatch
rpc_dispatch.gleamServer RPC dispatch
ssr_handler.gleamServer-side render entry
ws_handler.gleamWebSocket handler
http_handler.gleamHTTP RPC handler
protocol_wire.gleamProtocol facade

These files are derived from your page modules. You don’t edit them directly; re-running codegen overwrites them.

Generated client package

Rally also writes a standalone client package under .generated_clients/<namespace>/. This package has its own gleam.toml (targeting JavaScript), a generated SPA entry point, transport layer, tree-shaken copies of your page modules, and the codec for whatever protocol you selected.

The server project remains the source of truth. The client package is an output artifact, rebuilt on every codegen pass.

Protocols

The protocol field in a client entry selects the wire format used between client and server.

The generated protocol_wire.gleam facade adapts at compile time based on the selected protocol. Your application code never branches on protocol at runtime.

[[tools.rally.clients]]
namespace = "public"
protocol = "json"

Multiple clients

You can define more than one [[tools.rally.clients]] entry. Each gets its own namespace, route root, and protocol. Codegen runs once per entry, producing a separate set of generated server files and a separate client package.

A common setup: one client for the public site and another for an admin panel.

[[tools.rally.clients]]
namespace = "public"
route_root = "/"

[[tools.rally.clients]]
namespace = "admin"
route_root = "/admin"
protocol = "json"

Environment

Rally checks the APP_ENV environment variable at startup.

APP_ENV=prod gleam run
Search Document