live · runnableaihu-counter
Human render — try it
governedaihu-counter.aihuaihu961 B
// counter — prop count + action increment/decrement/reset

@state {
  let count = prop({ default: 0 })

  const increment = action(() => { count++ })
  const decrement = action(() => { count-- })
  const reset = action(() => { count = 0 })
}

@template {
  <section class="counter">
    <output class="count">{count}</output>
    <div class="controls">
      <button on:click={decrement} class="btn">−</button>
      <button on:click={reset} class="btn btn-ghost">Reset</button>
      <button on:click={increment} class="btn">+</button>
    </div>
  </section>
}

@style {
  .counter { display: grid; gap: 0.75rem; padding: 1.5rem; max-width: 14rem; }
  .count { font-size: 2.5rem; font-variant-numeric: tabular-nums; text-align: center; display: block; }
  .controls { display: flex; gap: 0.5rem; }
  .btn { flex: 1; padding: 0.5rem; cursor: pointer; border: 1px solid var(--border, #ccc); border-radius: 4px; }
  .btn-ghost { background: transparent; }
}

This counter is the real aihu-counter recipe, compiled at build and hydrated as an island — fully interactive right here. To change the source and recompile it in your browser, open theWASM playground:

Governed examples

9 · CI-built
G1
todo-mvcbuild
Core reactivity + template grammar
statederivedactioneffectonMounteach+16
G2
hacker-newscompile+smoke
SSR meta-framework
propactionrouteroute.dynamicdefineLoaderssr-hydration+11
G3
layoutsbuild
Router / layouts / navigation
routeroute.headroute.layoutoutleta-enhanced
G4
storefrontcompile+smoke
Data + app-state platform
statederivedactionprovideifeach+9
G5
realtime-scorescompile+smoke
Streaming / realtime
stateonMountonDisposewebsocketeachkey+3
G6
css-engine-utilitybuild
Styling system
routecss-utility-foldcss-container-querypkg:css-engine
G7
agent-driven-democompile+smoke
Agent surface / GX governance
stateactioneachkeyinterpolationaction.expose+3
G8
ssg-sitebuild
SSG / static output
output:staticrouteroute.headeachkeyinterpolation+12
G9
agent-hubcompile+smoke
Agent protocols (A2A + ACP)
statederivedactionprovideifeach+8

Cookbook recipes

20 shown
agentRun

Agent Weather

Agent-surface async fetch — prop city and action fetchForecast carry expose/describe so MCP agents can read and invoke them.

propprop.exposeprop.describestate+9
container

Accordion

Accordion — each/key over prop-provided items, show toggles the open panel, aria-expanded tracks state.

propstateactioneach+5
display

Clock

Real-time clock — onMount starts the interval, onDispose clears it; tick runs through an action.

stateactiononMountonDispose+1
display

Controller

controller() intrinsic — a ResizeObserver reactive controller with hostConnected/hostDisconnected lifecycle, writes routed through an action.

stateactioncontrollercontroller.describe+1
displayRun

Counter

Minimal reactive counter — prop-backed count with increment/decrement/reset actions.

propactionon:clickinterpolation
container

Modal

Modal dialog — aria() declares role/aria-modal on the host, show toggles visibility, Escape and backdrop click dismiss.

propariaactionshow+3
container

Tabs

Tabs — derived() computes the selected tab, each/key renders the tablist, onMount picks the initial tab.

propstatederivedaction+8
container

Toast

Toast — auto-dismiss via onMount setTimeout, manual dismiss action, aria-live polite status region.

propstateactiononMount+4
form

ARIA Form

Form-associated element — aria() maps role/label/describedby, form() exposes value and validity to the surrounding form.

ariastateformaction+2
container

Context Consumer

consume() intrinsic — reads the 'theme' token provided by an ancestor context-provider.

consumeinterpolation
container

Context Provider

provide() intrinsic — exposes a theme token to descendant consumers over the context prototype chain.

stateprovideactionslot+1
list

Data Table

Sortable data table — derived() sorts a copy of the prop rows, each/key renders rows, click headers to toggle direction.

propstatederivedaction+4
async

Fetch Resource

resource() intrinsic — async fetch with loading/error/value states rendered through an if/elseif/else chain.

propresourcegroupif+3
form

Form Validation

Live validation — form() exposes value/validity, derived() computes the error message, touched gates when errors show.

stateformderivedaction+5
agent

Guard UI

<guard> element — scope-gated UI that renders its children only when the 'admin' scope is verified.

guardinterpolation
list

Infinite Scroll

Infinite scroll — controller() wires an IntersectionObserver sentinel that calls the loadMore action; each/key/empty renders the list.

propstateactioncontroller+7
list

Search Debounce

Debounced search — bind:value feeds the query, effect() debounces 300ms into a second state, derived() filters results.

stateeffectderivedbind:value+6
ssr-ssg

SSR Hydration

SSR-safe bootstrapping — props render placeholders on the server; onMount reads server-stamped dataset values after hydration.

propstateonMountinterpolation
display

Tailwind Style

Tailwind utilities in the template coexisting with a scoped @style block for component-specific rules.

stateactionon:clickinterpolation
display

Theme Toggle

Theme switcher — state-backed theme is provided to descendants and mirrored onto documentElement by an effect.

stateprovideeffectaction+2