weft
ir 2.6.0 · warp 1.8.0

Adoption, signals, and what ships

No hydration: the server-rendered DOM is adopted, and what the client wires is one entry per binding.

<li>
<li>
<li>
<li>
<li>
~200 bindings recorded
one signal write
qty 2 → 3
0.31 µs, one node, no component code
Adopting a 50-row region costs 0.045 ms in Chromium against 0.077 ms to parse the same markup — and a 12-path delta applies in 0.0018 ms.
✓ Valid A signal, changed by an intent

Adoption records where each value lives; a write reaches those nodes and nothing else. The binding for an event is an intent name.

✕ Refused a shape a signal decides
what you wrote→a conditional shape belongs to the server→E_BRANCH_ON_SIGNAL

A conditional value over the same signal is reactive and allowed — the refusal names which one you wrote.

In plain terms

The browser does not re-render what the server sent. The runtime walks the DOM the parser already built, writes down where each value lives, and stops. After that, a change is one write to one node.

There is no hydration step. The server-rendered DOM is the DOM, and what the client does on arrival is adopt it: walk the wiring the compiler emitted and attach one binding per node that reads a value. No component code runs, so the cost is the number of bindings rather than the number of components.

A signal and a derived value

examples/signals

The derived expression travels as a tree the client evaluates. There is no closure on the wire and no component to hydrate.

output

14 × 1 = 14

over nine

app/fragments/examples/signals.tsx
import { fragment, signal } from '@weftjs/core'
import { quantity } from '../../intents/quantity.ts'

/**
 * A signal, and a value derived from it. `qty() * unitPrice` travels as a tree the client
 * evaluates, no closure or hydration needed. See `spec/ir/template-ir-2.md`.
 *
 * `value={qty()}` needs a property write, not an attribute write, once somebody has typed. See
 * `spec/compiler/supported-subset.md`: Controls. `onInput` names an intent — the only inbound
 * wiring op — or typing into this would do nothing. See `spec/ir/template-ir-2.md`: Wiring table.
 */
export default fragment(({ unitPrice }: { unitPrice: number }) => {
  const qty = signal(1)
  return (
    <form class="signals">
      <label>
        quantity
        <input type="number" name="qty" min="0" value={qty()} onInput={quantity} />
      </label>
      <p class="line">
        <span class="unit">{unitPrice}</span> × <output class="qty">{qty()}</output> ={' '}
        <output class="total">{qty() * unitPrice}</output>
      </p>
      <p class="over" data-over={qty() > 9}>
        over nine
      </p>
    </form>
  )
})
What the compiler knows
Holes5
Escape elided0
Effect setnone — static
Wire formshtml · bundle · split · patch · delta

Holes

BindingHoleEscape
qtyattrproven-safe
unitPricetextproven-safe
qtytextproven-safe
d0textproven-safe
d1attrproven-safe

What the client wires on adoption

OpBindsWhere
propqtyvalue at [0, 0, 0]
eventintent 858420input at [0, 0, 0]
textqtytext at [0, 1, 1]
textd0text at [0, 1, 2]
attrd1data-over at [0, 2]
SignalTypeInitial
qtynumber1
Sealed templates
1
Version
334da034466c5f38bbb4b26c5b0e20d5
Derived
d0 ← qty, unitPrice, d1 ← qty

The facts below list a wiring entry per node that reads the signal. That is the cost model: bindings, not components.

Signals, and values derived from them

A signal is client-owned state. The server renders it at its initial value, and from adoption onwards the browser owns it. A value computed from a signal is a derived value, and the expression travels on the wire as a tree the client evaluates — which is what lets a page recompute it without shipping the component that wrote it.

The graph is pull-based with linked edges: setting a signal marks its readers stale and nothing recomputes until it is read. So a value nobody is looking at costs nothing when its input changes.

What the page actually downloads

Entries, not a bundle. A page that only adopts and binds imports the adoption path and nothing else; deltas, epochs, the channel, navigation, staging and discovery are each a further entry, and a page that links nowhere does not carry the staging model. Every one has a ceiling and a test that fails when it is crossed.

The ceilings, the entries they cover, and the number that is bigger than all of them are on what the page downloads.