Client state
A client state lives in the browser — the runtime reflects it, without ever touching the server. It is the right choice for pure UI: a panel open or closed, a display filter, a local preference.Declaring, and persistence
One inherits from `ClientState`. `persist=` decides one thing only: how long the value survives.class FilterUI(ClientState, persist="local"):
sort_by: str = "date"
| persist= | Survives | What for |
|---|---|---|
| "memory" (default) | throwaway — lost on reload (F5) and on close | a UI flag (menu open) |
| "session" | survives a reload, lost on close | a filter, a wizard step |
| "local" | survives everything | a real preference (theme, sort) |
Demo — the client mirror, zero round trips
The input writes into a ClientState; the text below reflects it through `bz-text`. No network — the runtime swaps the text on every keystroke.Live echo:
See the emitted HTML
Summary
EchoClientClientStatepersist='local'
| Field | Type | Default | @validator |
|---|---|---|---|
| text | str | '' | — |
Driving that state from an event:Client actions →· the live reflection in detail:Client reactivity →