Adoption, signals, and what ships
No hydration: the server-rendered DOM is adopted, and what the client wires is one entry per binding.
Adoption records where each value lives; a write reaches those nodes and nothing else. The binding for an event is an intent name.
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/signalsThe derived expression travels as a tree the client evaluates. There is no closure on the wire and no component to hydrate.
app/fragments/examples/signals.tsximport { 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
Holes
| Binding | Hole | Escape |
|---|---|---|
qty | attr | proven-safe |
unitPrice | text | proven-safe |
qty | text | proven-safe |
d0 | text | proven-safe |
d1 | attr | proven-safe |
What the client wires on adoption
| Op | Binds | Where |
|---|---|---|
prop | qty | value at [0, 0, 0] |
event | intent 858420 | input at [0, 0, 0] |
text | qty | text at [0, 1, 1] |
text | d0 | text at [0, 1, 2] |
attr | d1 | data-over at [0, 2] |
| Signal | Type | Initial |
|---|---|---|
qty | number | 1 |
- 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.