Skip to content
scalive
Menu
ConnectingLiveReconnectingOffline

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]:

  • Model is the page state.

  • Msg lists the interactions the page accepts.

  • mount creates the starting state.

  • handleMessage turns a message and the current state into the next state.

  • view 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

ConcernServerBrowser
Application stateOwns models, transitions, services, and durable dataKeeps the rendered DOM and intentional browser-local state
RenderingProduces typed HTML and updatesApplies patches to the existing DOM
EventsResolves bindings to typed messages and runs handlersCaptures DOM events and sends binding data
EffectsRuns ZIO effects, async work, and subscriptionsRuns hooks and commands that require browser APIs
ConnectionValidates the join and owns connection-scoped resourcesOpens, monitors, disconnects, and reconnects LiveSocket
SecurityTreats URLs, connect parameters, and event payloads as untrustedIs not an authority for identity or authorization

Take The Ordered Path

The pages build one mental model in this order:

  1. Quick start creates and runs a complete standalone counter.

  2. Project anatomy assigns startup, routing, layout, LiveView, asset, and browser responsibilities.

  3. Models, messages, and effects explains immutable state, typed intent, and the small ZIO vocabulary used by Scalive.

  4. URL state and navigation covers typed routes, URL-driven state, and live navigation.

  5. Rendering, bindings, and diffs follows one update from typed HTML to a browser DOM patch.

  6. Lifecycle, state ownership, and reconnects explains mount phases, resource lifetime, failures, cleanup, and remounting.

  7. 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.