Global State
Global state is always accessible from any expression. Values enter global state from three sources:AppResult — the initial state set by your server code:
name prop syncs its current value to state automatically. Input(name="city") updates {{ city }} on every keystroke.
Actions — SetState and ToolCall (via result_key) write to global state when they fire.
Local Scope
The State component provides scoped values to its children. These shadow global state within the subtree — inner values win over outer ones for the same key. The firstText renders “Don’t Panic, Arthur”. The second renders “Don’t Panic, Ford” — the inner State shadows name but inherits greeting from the outer scope.
Dot Paths
Use dot notation to reach into nested objects:.length works on both arrays and strings. If any segment of the path is null or undefined, the entire expression resolves to undefined.
Special Variables
Several variables are injected automatically by the framework in specific contexts.$event
Available inside action specs. Contains the value from the triggering interaction — what that means depends on the component:
| Component | $event value |
|---|---|
| Input / Textarea | Current text (string) |
| Slider | Current position (number) |
| Checkbox / Switch | Checked state (boolean) |
| Select | Selected value (string) |
| RadioGroup | Selected value (string) |
| Button | undefined |
"{{ $event }}" when no explicit value is provided, which is why SetState("volume") on a slider captures the slider position.
$error
Available inside on_error callbacks. Contains the error message string from the failed action.
$index
Available inside ForEach iterations. The zero-based index of the current item.
$index is how actions target specific list items from inside a loop — SetState("todos.{{ $index }}.done") updates the done field of the item at the current position.
$item
Available inside ForEach iterations. A reference to the entire current item object. Individual fields are also available directly ({{ name }} instead of {{ $item.name }}), but $item is useful when you need to pass the whole object to an action: