Examples
Working code before explanation, so you can see what the API does and then read why it works. Every WASM demo has a compiled-markup twin with the same behaviour — the JavaScript generated at build time and embedded in the page (view source: no WASM loaded), or full Go in the browser when you need it. The last few pages are code-only: templ authoring and the parts of astwerk that build a site rather than run in one. Starting from nothing instead? The Build a site tutorial goes step by step from go mod init to a deployed site.
Compiled markup (x)
Counter x.Text
A signal, a derived double, and +/−/reset handlers — compiled to JavaScript at build time.
Keyed list x.List
Add and remove todos; rows are keyed, so nodes move instead of rebuilding.
Forms & computed x.Number
Two-way number inputs and an x.Computed total, compiled to JavaScript.
Attribute bindings x.Attr
x.Attr, x.Class, x.Disabled and x.Style — each owning one property.
Async data x.Script
A fake fetch through the script escape hatch: loading, data, reload.
Canvas x.Script
A canvas animation where the escape hatch is the whole answer.
FAQ x.When
Answers mount and unmount as x.When toggles — a conditional subtree.
Under the hood x.Document
The exact HTML and script the build emitted for a widget, shown on the page itself.
WASM demos
Counter reactive
The same counter — signal, computed double, three handlers — in Go compiled to WebAssembly.
Keyed list BindList
Moving nodes instead of rebuilding them, keyed by id.
Form bindings BindNumber
Two-way number inputs and a computed total.
Attribute bindings BindAttr
BindAttr, BindClass and BindStyle — one property per binding.
Async data Resource
A Resource's loading, error and data states, all as signals.
Canvas wasmwrap
A typed 2D context and an animation loop.
Stopwatch SetInterval
A timer ticking a signal — time is just another value.
Filter Computed
A search box deriving a filtered slice, rendered by BindList.
In code
Templ basics templ
Components, children, escaping, if/for — the authoring model every astwerk page is built from.
Tree & content ssg.Node
ssg.Node, Build, markdown collections and locales.
Scripts & routing CompileFrom
CompileFrom and reactive.Router — why the router isn't live here.
wasmwrap & templ BindTempl
Raw DOM scripting without reactive, and re-rendering templ client-side.