Learn
Start Here
Scalive lets you build interactive pages in Scala while keeping application state on the server. The server renders HTML and handles interactions. The browser shows that HTML, sends events such as clicks and form changes, and applies the small updates returned by the server.
Ready to build something? Create and run the counter in Quick start.
The central type is a
LiveView[Msg, Model]trait LiveView[Msg, Model]Defines a server-rendered view with typed messages and model state.:
Modelis the page state.Msglists the interactions the page accepts.mountdef mount(ctx: MountContext): zio.package.Task[Model] creates the starting state.handleMessagedef handleMessage(model: Model, ctx: MessageContext): Msg => zio.package.Task[Model]Handles a message against the current immutable model. turns a message and the current state into the next state.viewdef view(model: Signal[Model]): HtmlElement[Msg] describes the HTML for that state and binds browser events to messages.
The basic loop is: render a page, receive a typed message, update the model, and patch the changed HTML. Most application behavior stays in Scala; use browser JavaScript only for features that require browser APIs.
The lifecycle page explains how the initial HTTP response, live connection, and reconnects relate. The runtime architecture is available when you need implementation details.
Know Which Side Owns What
| Concern | Server | Browser |
|---|---|---|
| Application state | Owns models, transitions, services, and durable data | Keeps the rendered DOM and intentional browser-local state |
| Rendering | Produces typed HTML and updates | Applies patches to the existing DOM |
| Events | Resolves bindings to typed messages and runs handlers | Captures DOM events and sends binding data |
| Effects | Runs ZIO effects, async work, and subscriptions | Runs hooks and commands that require browser APIs |
| Connection | Validates the join and owns connection-scoped resources | Opens, monitors, disconnects, and reconnects LiveSocket |
| Security | Treats URLs, connect parameters, and event payloads as untrusted | Is not an authority for identity or authorization |
Take The Ordered Path
The pages build one mental model in this order:
Quick start creates and runs a complete standalone counter.
Project anatomy assigns startup, routing, layout, LiveView, asset, and browser responsibilities.
Models, messages, and effects explains immutable state, typed intent, and the small ZIO vocabulary used by Scalive.
URL state and navigation covers typed routes, URL-driven state, and live navigation.
Rendering, bindings, and diffs follows one update from typed HTML to a browser DOM patch.
Lifecycle, state ownership, and reconnects explains mount phases, resource lifetime, failures, cleanup, and remounting.
Where to go next maps common application needs to the relevant guides, examples, and API reference.
Scalive is alpha software. These pages describe the current recommended API and may change when a clearer or safer Scala design becomes available.