SetState("count", "{{ count + 1 }}"). The expression count + 1 evaluates against the current state, updates the count key, and every {{ count }} reference in the UI re-renders with the new value.
What Expressions Can Do
Expressions handle display-time computation — formatting values, computing derived text, and making rendering decisions:- Arithmetic —
{{ price * quantity }},{{ count + 1 }} - Comparisons —
{{ score > 90 }},{{ status == 'active' }} - Conditional text —
{{ active ? 'Online' : 'Offline' }} - String building —
{{ first + ' ' + last }} - Formatting —
{{ price | currency }},{{ name | upper }} - Conditional rendering —
If("inventory > 0")/Elif/Else
What They Can’t
Expressions are deliberately restricted to evaluating scalar values — numbers, strings, booleans. They cannot construct objects, call functions, make network requests, or produce side effects. Prefab splits interactive behavior into three layers, each with a clear scope:
If you find yourself wanting to write application logic inside a
{{ }} template, that computation belongs in a ToolCall instead.
Where Expressions Appear
The same expression language is used in three places, each with a slightly different purpose: Templates embed expressions inside string props using{{ }} delimiters. The renderer evaluates the expression and substitutes the result. Every string prop on every component supports this — labels, placeholders, URLs, CSS classes, action arguments, anything.
If, Elif, and Else blocks to show or hide components based on expression results. Each condition evaluates to a truthy or falsy value, and the first matching branch renders.
Grammar
The complete expression grammar, from lowest to highest precedence:{{ status == 'active' }}. Numbers can be integers or floats. Identifiers resolve as dot-paths against the current context.