Follow the guided introduction, inspect the working examples, or use the API reference when you already know what you need.
Scala 3 · Server rendered · Fully typed
Live interfaces. Typed end to end.
Build real-time web applications entirely in Scala. Keep state and rendering on the server, handle browser events as typed messages, and send efficient HTML updates over the wire.
import zio.{Task, ZIO}
import scalive.*
final class CounterLiveView extends LiveView[CounterLiveView.Msg, Int]:
import CounterLiveView.Msg
def mount(ctx: MountContext): Task[Int] =
ZIO.succeed(0)
def handleMessage(model: Int, ctx: MessageContext) =
case Msg.Decrement => ZIO.succeed(model - 1)
case Msg.Increment => ZIO.succeed(model + 1)
def view(model: Signal[Int]): HtmlElement[Msg] =
mainTag(
h1("Scalive counter"),
button(on.click(Msg.Decrement), "Decrease"),
outputTag(aria.live := "polite", model.map(_.toString)),
button(on.click(Msg.Increment), "Increase")
)
object CounterLiveView:
enum Msg:
case Decrement, IncrementView source (documentation/fixtures/quick-start/src/quickstart/CounterLiveView.scala:5-29)
Live result
Click Increase to send Msg.Increment to the server.
Current modelcount =0
This example is read-only while disconnected. Controls resume after reconnection.
One typed model. State, messages, transitions, and rendering remain explicit and compiler checked.
HTML from Scala. Build interfaces with a typed HTML DSL instead of maintaining a separate frontend component tree.
Live over the wire. Browser events reach the server as typed messages; Scalive sends efficient HTML diffs back.
How it works
One event travels through a small, observable server-owned loop.
Browser event. A user interaction is sent over the live connection.
Typed message. The event is decoded into a message your
LiveViewtrait LiveView[Msg, Model]Defines a server-rendered page with typed messages and model state. accepts.Server transition. Your handler updates typed state and can run ZIO effects.
HTML diff. Scalive renders the next view and sends only the changes to the browser.
Why Scalive
Scalive brings the Phoenix LiveView model to Scala 3 and ZIO. A
LiveViewtrait LiveView[Msg, Model]Defines a server-rendered page with typed messages and model state.
describes its initial state, transitions, effects, and rendered output without
introducing a separate frontend component framework.
It is designed for Scala teams that want interactive applications while keeping domain logic, UI state, and effect handling in one typed server-side system. Read why I built Scalive for the journey that led to this design.
Scala 3
ZIO effects
Server-owned state
Typed HTML
Phoenix LiveView semantics