Solid 2.0 components and rendering (TypeScript)
The authoring layer above Solid 2.0's signals: components that run once, a compiler that lowers JSX to template clones plus one reactive binding per dynamic hole, control flow written as ordinary components that own their child scopes, and a twelve-operation host contract (@solidjs/universal, two of them optional) that lets the same output drive a non-DOM tree.
| Field | Value |
|---|---|
| Language | TypeScript; JSX or TSRX source compiled by @solidjs/babel-plugin or the Rust/Oxc @solidjs/compiler; compiler-free authoring through @solidjs/h and @solidjs/html |
| License | MIT (LICENSE) |
| Repository | solidjs/solid: packages/solid, packages/web, packages/universal, packages/babel-plugin, packages/compiler, packages/h, packages/html, packages/element |
| Documentation | Components and JSX (solid-docs v2-rebuild) · RFCs [03 control flow][rfc03], [07 DOM][rfc07], [09 TypeScript/JSX][rfc09] · MIGRATION.md · TSRX frontend notes |
| Category | compiled fine-grained rendering: no virtual DOM, no re-render; reactivity is attached per expression |
| Versions surveyed | solid-js@2.0.3, @solidjs/web@2.0.3, @solidjs/universal@2.0.3, @solidjs/babel-plugin@2.0.2, @solidjs/compiler@2.0.2, @solidjs/h@2.0.2, @solidjs/html@2.0.1 (commit 68406c2, 2026-11-19); solid-docs at c32486f; solid-js@1.9.15 for 1.x |
| Core abstraction | a component is a plain function called once under untrack; what it returns is a value (a node, an array, or an accessor) that insert binds to a parent through a render effect |
NOTE
This page is the companion of Solid 2.0 signals, which covers the graph underneath: ownership, memos, effects, async, batching. It does not repeat them; where a rendering mechanism rests on a signals rule, it links to the section that states the rule. Everything here was read from source at the pinned commit; behaviour named only in docs is marked as such.
Overview
What it solves
A UI framework built on fine-grained signals still has to answer four questions the graph does not: what a "component" is when nothing re-runs it, which parts of a template are reactive, how a list or a branch creates and destroys the subtrees under it, and how the result reaches a concrete node tree. Solid's answer is that the component disappears at runtime and the compiler does the bookkeeping. The 2.0 docs open the components page with the rule everything else follows from (components-and-jsx.mdx):
"A Solid component is a function that runs once. It sets up state, returns JSX, and is not called again for the life of the component."
and on what JSX becomes (components-and-jsx.mdx):
"Solid compiles JSX into renderer operations. […] There is no virtual DOM value that Solid repeatedly rebuilds and compares."
Design philosophy
- The reactivity boundary is the expression, not the component. "Each JSX expression the component returns is its own tracking scope with its own dependencies" (
components-and-jsx.mdx). A change re-runs one binding; the function that created it never runs again. This is the inverse of Jetpack Compose, where the recomposition scope is a composable function. - Let the compiler decide what is static. "A heuristic wraps expressions that contain function calls or property access; simple literals and variables stay unwrapped" (babel-plugin
README.md). Static markup goes into a cloned template; only holes get runtime work. - Control flow is library code.
For,Show,Switch,LoadingandErroredare components inflow.tsbuilt from memos andmapArray; the runtime has no special node kind for them. - The renderer is swappable.
solid-jsowns the component model;@solidjs/web,@solidjs/hand custom renderers own their JSX types (RFC 09), and@solidjs/universalexposes the host operations so that "Solid [can] render to different platforms like native mobile and desktop, canvas or WebGL, or even the terminal" (universalREADME.md).
The component model
A component is a call, not a node
The compiler emits createComponent(Comp, props) for every capitalized tag (isComponent: an uppercase first letter, a dotted name, or a non-letter first character). In production that call is one line (component.ts):
// packages/solid/src/client/component.ts — createComponent (production path)
return untrack(() => Comp(props || ({} as T)));There is no component instance, no owner, no lifecycle record: the function runs untracked, so reads in its body subscribe nothing, and whatever primitives it creates attach to the caller's current owner. Dev and observe builds wrap the call in observedComponent, a transparent createRoot that carries the component's label so diagnostics can print <TodoRow>; its doc comment is explicit that "The prod build never calls this" (core.ts). 1.x had the same shape (component.ts at 1.9.15).
Because the body is untracked, a top-level read freezes its value. 2.0 makes that loud: "reading reactive values at the top level of a component body (including destructuring props) will warn" (MIGRATION.md) with STRICT_READ_UNTRACKED (RFC 08).
Props are getters
A literal attribute becomes a data property of the props object; an expression the heuristic calls dynamic becomes a getter, so the read happens wherever the child reads props.x, inside the child's tracking scope. From the universal fixture (input, output):
// packages/babel-plugin/test/__universal_fixtures__/components/code.js
const template2 = (
<Child
name="Jake"
dynamic={state.data}
stale={/*@static*/ state.data}
handleClick={clickHandler}
hyphen-ated={state.data}
ref={el => (e = el)}
/>
);// …/components/output.js
const template2 = _$createComponent(Child, {
name: "Jake",
get dynamic() {
return state.data;
},
stale: state.data,
handleClick: clickHandler,
get "hyphen-ated"() {
return state.data;
},
ref: el => (e = el)
});children follows the same rule: <Child><div /></Child> compiles to get children() { return _$createElement("div"); } (output), so "Non-expression children evaluate lazily on access" (babel-plugin README.md). The props object is therefore an ordinary object, not a proxy. Proxies appear only when props are combined: merge(...) and omit(...) return live views (a Proxy where the platform supports one, a getter-forwarding copy otherwise), whose reads "go to the source that owns the key (a getter runs there, a data property is read live)" (merge, omit).
The getter/data split is also visible at runtime. isStatic(props, key) (exported from solid-js) reports whether the caller wrote a literal, because "the compiler encodes a literal at the call site (as="button") as a data property and an expression […] as a getter" (isStatic); a library can then skip a computation for a literal prop.
The reactivity boundary is the expression
Compiled output makes the boundary concrete. The README's benchmark row (babel-plugin README.md) destructures item (so item is static for that row), reads selected() (a signal) and item.label (a property access):
// packages/babel-plugin/README.md — compiled output (excerpt; comments added)
_$insert(_el$2, itemId); // static: assigned once
_el$4._$$click = e => select(item, e); // handler: assigned once, never wrapped
_$insert(_el$4, () => item.label); // dynamic: one render effect
_$effect(
() => selected(), // compute: tracked
_v$ => _$className(_el$, itemId === _v$ ? "danger" : "") // apply: untracked DOM write
);Each insert(..., () => …) and effect(compute, apply) is a render effect on the signals graph: its compute half tracks, its apply half writes the node. When selected() changes, only the className write re-runs; view itself is gone.
The compile step
Templates and holes
For the DOM target, each element subtree becomes one template(html) call hoisted to module scope. At runtime template parses the HTML once and returns a function that clones it (cloneNode(true), or importNode for templates holding custom elements) (template). The compiled code then walks to the nodes that carry dynamic parts with firstChild/nextSibling chains and calls insert(parent, value, marker) for each child hole. From textInterpolation (output):
// <span>Hello {name}</span>
var _tmpl$ = /*#__PURE__*/ _$template(`<span>Hello `);
var _el$4 = _tmpl$();
_$insert(_el$4, name, null);
// let value = "World"; <span>Hello {value + "!"}</span>
_tmpl$0 = /*#__PURE__*/ _$template(`<span>Hello World!`);The second case shows constant folding: getStaticExpression asks Babel to evaluate() a child expression and inlines a string or number result into the template (utils.ts). Adjacent holes get <!> comment markers in the template so each insert has an anchor (_tmpl$4 = template('<span> <!>') in the same fixture).
Static versus dynamic: the heuristic
isDynamic (utils.ts) is purely syntactic. An expression is dynamic if it is, or contains outside a nested function, a call (including optional and tagged-template calls and import()), a member access (except on a namespace import), an optional member access, a spread, an in test, or — where JSX counts — a nested JSX element. Functions are never dynamic; a leading /*@static*/ comment (the configurable staticMarker) forces static (babel-plugin README.md). An identifier is static. The attributeExpressions fixture shows the split on two otherwise identical attributes (output):
// <div textContent={rowId} /> and <div textContent={row.label} />
_el$5.textContent = rowId;
_$effect(
() => row.label,
_v$ => {
_el$7.data = _v$;
}
);Child holes are more forgiving than attributes. insert checks typeof accessor !== "function" at runtime and treats a function value as reactive (insert), so {count} with count a signal getter still updates; textContent={count} assigns the function itself.
One effect per template
When an element group has several dynamic attributes, the compiler merges them into one effect whose compute returns an object and whose apply diffs each field against the previous run. From the same fixture (input, output):
// <input value={s()} min={min()} max={max()} … /> <input checked={s2()} min={min()} max={max()} … />
// (attributeExpressions/output.js, compute object joined onto one line)
_$effect(
() => ({ e: s(), t: min(), a: max(), o: s2(), i: min(), n: max(), s: _$heldRead() }),
({ e, t, a, o, i, n, s }, _p$) => {
(e !== _p$?.e || !s) && (_el$24.value = e ?? "");
t !== _p$?.t && _$setAttribute(_el$24, "min", t);
a !== _p$?.a && _$setAttribute(_el$24, "max", a);
(o !== _p$?.o || !s) && (_el$25.checked = o);
i !== _p$?.i && _$setAttribute(_el$25, "min", i);
n !== _p$?.n && _$setAttribute(_el$25, "max", n);
}
);RFC 07 gives the reason and the cost: stateful properties "share the template's grouped effect (one effect per template keeps rows cheap), so when class={cls()} on the same element — or on any element in that template — changes, the effect re-runs and writes value again" (RFC 07). heldRead() is the hook into the signals hold machinery that stops a re-run from writing a held value back over typed text.
Conditionals are memoized
A ternary or && whose branches are dynamic and whose test is dynamic is rewritten so the test runs in its own memo, coerced to boolean (transformCondition). From conditionalExpressions (output):
// <div>{state.dynamic ? good() : bad}</div>
_$insert(
_el$6,
(() => {
var _c$ = _$memo(() => !!state.dynamic);
return () => (_c$() ? good() : bad);
})()
);The memo is what makes a branch stable. The hole's render effect owns whatever its compute creates, and a re-run disposes the previous run's children (signals: lifetime and ownership); without the boolean memo, a truthy-to-truthy change of state.dynamic would re-run the branch and rebuild it. The wrapConditionals option (default on) controls this (babel-plugin README.md).
The compiler knows some components
Two features tie the compiler to specific component names. builtIns auto-imports For, Show, Switch, Match, Loading, Reveal, Portal, Repeat, Dynamic and Errored from moduleName when they appear in JSX (babel-plugin README.md). And in production builds lowerShow replaces a <Show> imported from solid-js or @solidjs/web with the memoized ternary it would render, "minus the component call, the props object with its getters, and two of its three memos", when the when expression is safe to read twice (lower-show.ts; fixture output). Dev builds keep the component.
Runtime primitives the output calls
| Primitive | Where | Role |
|---|---|---|
template(html, flag?) | client.ts | parse once, clone per instance |
insert(parent, accessor, marker?, init?, options?) | client.ts | bind a child hole: a non-function value is inserted once; a function gets a render effect, and a function returned by it gets a nested one |
effect(compute, apply, options?) | render.ts | createRenderEffect with { transparent: true, sync: true }: one attribute binding or one grouped template effect |
memo(fn) | render.ts | createMemo(fn, { sync: true }): condition memos |
createComponent(Comp, props, name?, loc?) | component.ts | the untracked call above; name/loc only under sourceNames |
mergeProps(...), spread(node, props, skipChildren) | client.ts | {...props} on components and elements: one props effect plus one children insert |
setAttribute, className, style, setProperty, addEvent | client.ts | the write helpers an apply half calls |
delegateEvents(names) | client.ts | declares which event names the module needs delegated |
ref(() => value, el), applyRef(value, el) | client.ts | resolve a ref value untracked and call it (or each entry of a nested array) with the element |
The universal target replaces template and the DOM helpers with createElement, createTextNode, insertNode and setProp (below).
Two compilers, one corpus
@solidjs/compiler is a native Oxc port and "the default in vite-plugin-solid"; the Babel plugin is "the JavaScript fallback" (babel-plugin README.md). The Rust tests read the Babel fixtures directly and classify each one's parity (babel-fixtures.test.js). Both accept a second syntax: TSRX (TypeScript Render Extensions), an external draft language (specification snapshot, "Draft / June 7, 2026") whose @if/@for … @empty/@switch/@try … @pending … @catch blocks desugar to Show, For, Switch/Match, Loading and Errored before the shared JSX lowering runs (TSRX frontend notes; babel-plugin README.md). It is marked experimental and adds no runtime concept: the lowering table maps every construct to an existing component.
Authoring without a compiler: h and html
Both packages trade the compiler's static analysis for a runtime convention. The h README is blunt: it "cannot leverage anything in the way of analysis, so it requires manual wrapping of expressions" (@solidjs/h README).
What is lost. No static/dynamic split, so the author marks every reactive expression by wrapping it in a function (h("div", { id: () => props.id }, () => firstName() + lastName())). No variable-assignment refs (ref={el}), only callbacks. No grouped template effects: @solidjs/html routes the props of every element that has any through the general spread path (renderChildren), and h uses spread whenever any prop is dynamic and assign otherwise (materialize). h also cannot hoist templates; html recovers that part by parsing each TemplateStringsArray once into a cached AST plus a <template> element and cloning it per call (getCachedRoot).
How reactivity is reconstructed: function arity. The convention is a zero-argument function is a reactive value; a function with parameters is a callback. h turns every zero-arity function prop of a component into a getter and wraps higher-arity callbacks so the h thunks they return materialize at the call site (componentProps); on elements, zero-arity function values become getters except ref and on[A-Z]… handlers (materialize). html applies the same rule through applyGetter (tagged-jsx.ts). The consequence is documented as a caveat: an event handler on a component must declare its event parameter, or it becomes a getter that runs when the child reads it (h README; html README).
Thunks stand in for lazy children. h(...) returns a tagged thunk ($ELEMENT) that builds its node under untrack only when consumed, which is how h reproduces JSX's lazy get children() (h). The README warns that wrapping it once more (render(() => h(App), el)) "adds one function too many": the renderer then treats the inner thunk as a reactive expression and re-creates the component whenever its output changes (h README).
IMPORTANT
Both compiler-free forms are DOM-only at this commit: hyperscript.ts and tagged-jsx.ts import insert, spread, createComponent and the element tables from @solidjs/web (hyperscript.ts, tagged-jsx.ts). A custom renderer built on @solidjs/universal has no compiler-free authoring path.
The universal renderer contract
Host operations
createRenderer(options) takes the host's node operations and returns the runtime the generate: "universal" compiler output imports (universal README.md). The full option interface (universal.ts):
// packages/universal/src/universal.ts — RendererOptions
export interface RendererOptions<NodeType> {
createElement(tag: string, staticProps?: Record<string, unknown>): NodeType;
createTextNode(value: string): NodeType;
createSentinel?(): NodeType;
replaceText(textNode: NodeType, value: string): void;
isTextNode(node: NodeType): boolean;
setProperty<T>(node: NodeType, name: string, value: T, prev?: T): void;
insertNode(parent: NodeType, node: NodeType, anchor?: NodeType): void;
removeNode(parent: NodeType, node: NodeType): void;
cleanupNodes?(parent: NodeType, nodes: NodeType[]): void;
getParentNode(node: NodeType): NodeType | undefined;
getFirstChild(node: NodeType): NodeType | undefined;
getNextSibling(node: NodeType): NodeType | undefined;
}| Operation | Called by | Contract notes |
|---|---|---|
createElement(tag, staticProps?) | compiled output | staticProps carries the literal props the compiler batched (_$createElement("div", { textContent: rowId }), fixture) |
createTextNode(value) | compiled output; normalize for string/number children (source) | text leaves |
createSentinel?() | insert for an empty multi-child region (source) | defaults to createTextNode(""); holds the region's slot among siblings |
replaceText(textNode, value) | insertExpression, text-to-text update (source) | applied to getFirstChild(parent) |
isTextNode(node) | nothing | required by the type and destructured in createRenderer (source), but no call site in universal.ts at this commit |
setProperty(node, name, value, prev?) | setProp in compiled effects; spread's apply half, which also calls it with undefined for a key that disappeared (source) | every attribute, event handler, style and class goes through it; the host interprets names (the README example lowercases on* names) |
insertNode(parent, node, anchor?) | compiled output, insertExpression, reconcileArrays (source) | anchor undefined means append |
removeNode(parent, node) | cleanChildren, reconcileArrays | detach only; disposal of reactive state is the owner tree's job |
cleanupNodes?(parent, nodes) | the disposer render returns (source) | default removes each node still under parent |
getParentNode(node) | reconcileArrays liveness check, cleanChildren | identity comparison against the parent |
getFirstChild(node) | text replacement, single-child replacement, render's mount bookkeeping | |
getNextSibling(node) | reconcileArrays anchor computation |
The contract is a mutable, ordered child list with stable node identity, plus a property setter that receives the previous value. Nothing in it is DOM-specific: no event model, no namespace, no template, no layout.
What createRenderer returns
render, effect, memo, createComponent, createElement, createTextNode, insertNode, insert, spread, setProp, mergeProps, applyRef and ref (Renderer). effect and memo are the same sync render effect and sync memo the web runtime uses (source); createComponent and mergeProps are re-exported from solid-js. insert follows the web algorithm: a function accessor gets a render effect, a function returned from it gets an inner effect (scheduled into the effect phase after the first run), and the apply half calls insertExpression, which replaces text, cleans children, or reconciles arrays (insert). render mounts through insert with { schedule: true } and drains with flush(), so a top-level async read holds the first commit the same way it does on the web (universal README.md). The README also tells the host to re-export For, Repeat, Show, Switch, Match, Errored, Loading and Reveal from solid-js, which work unchanged because they are renderer-neutral (universal README.md).
What the output looks like
Universal output has no templates: every element is a createElement call, every static child an insertNode, every dynamic attribute an effect whose apply calls setProp with the previous value. From the attributeExpressions universal fixture:
var _el$5 = _$createElement("div"),
_el$6 = _$createElement("div", { textContent: rowId }),
_el$7 = _$createElement("div"),
_el$8 = _$createElement("div", { innerHTML: "<div/>" });
_$insertNode(_el$5, _el$6);
_$insertNode(_el$5, _el$7);
_$insertNode(_el$5, _el$8);
_$spread(_el$5, () => getProps("test"), true);
_$effect(
() => row.label,
(_v$, _$p) => {
_$setProp(_el$7, "textContent", _v$, _$p);
}
);A host also supplies its own JSX types (jsx-runtime/jsx-dev-runtime entries describing its intrinsic elements); the README ships a minimal template (universal README.md). generate: "dynamic" mixes the two outputs, routing a configured set of tags to the DOM renderer (compiler README.md).
What a universal host does not get
- No event delegation. Delegation,
delegateEventsand the_$$clickhandler slots are@solidjs/webcode; the universal compiler emits no event handling (universal/element.ts), soonClickreachessetPropertyas a function-valued prop. - No template cloning. Every instance runs the full
createElement/insertNodesequence. - A different list diff. Universal
reconcileArraysis the classic prefix/suffix/end-swap/map loop (source); the web one (reconcile.ts) addsmoveBefore, slot ownership tags and an index-stamp map. - No hydration and no compiler-free authoring (see above).
Control flow as components
Every control-flow component returns an accessor (a memo, or a function over one) that insert binds like any other dynamic child. What it creates inside that memo's run is owned by the run, so the signals ownership rule — a re-run disposes the previous run's children — is the whole disposal mechanism.
Show, Switch/Match: one memo per decision
Show builds three memos (flow.ts): conditionValue reads props.when; condition wraps it with equals: (a, b) => !a === !b, so it only changes when truthiness flips; and the output memo reads condition() and, when truthy, calls the children. Non-keyed, a truthy-to-truthy change of when therefore does not re-run the output memo, and the child stays mounted while its accessor (u()) reads the new value. keyed drops the boolean memo, so any identity change of when re-runs the output memo, disposes the old branch, and mounts a new one with the raw value. The function-child form is detected by arity, typeof child === "function" && child.length > 0, and called under untrack. Switch resolves its children with children(), chains one condition memo per Match so later matches read undefined once an earlier one wins, and picks the first truthy one (flow.ts); Match itself just returns its props (flow.ts).
For: two reconciliations
For is a thin wrapper that, on first read (at creation while hydrating), calls mapArray(() => props.each, props.children, options) under its own owner (flow.ts). Its options are read once: { keyed: props.keyed } is captured at creation, which is why RFC 03 says to "avoid dynamic boolean keyed values with function children" (RFC 03). The three modes (RFC 03, mapArray):
keyed | Row identity | Callback receives | Per-row signals |
|---|---|---|---|
absent / true | item === | raw item, index accessor | an index signal only if the callback declares an index parameter |
false | position | item accessor, numeric index | an item signal per row (the 1.x Index) |
(item) => key | key(item) | item accessor, index accessor | item and index signals |
Reconciliation happens twice, at two levels.
- Data level,
mapArray(updateKeyedRows). Each row is mapped under a freshcreateOwner(). A pass skips the common prefix and suffix (writing a changed item into its row signal in the accessor modes), returns early with the same mapped array if nothing moved, tries a bounded small-move fast path on large windows, and otherwise builds aMapfrom key to new positions over the changed window, carries matched rows (mapping, owner, row and index signals) to their new slots, creates new rows under new owners, and disposes the owners of rows that left. Passes are staged: a mapper that throws (for exampleNotReadyErrorfrom an async read) disposes only the owners that pass created and leaves the previous state intact for the retry (map.ts). A fresh_mappingsarray identity is the change signal downstream. - Node level,
insert→reconcileArrays. The mapped array is an array of nodes, andinsertExpressiondiffs it against the nodes currently in the parent: a "slightly modified version of" WebReflection's udomdiff (reconcile.ts) with prefix/suffix skipping, end swaps, and a map fallback that uses an index stamp on each new node; on the web it moves connected nodes withmoveBefore()where available so focus survives (reconcile.ts).
Rows that survive keep their owner, so their effects and DOM are untouched; a removed row's owner is disposed, which runs its cleanups and drops its effects. 1.x used the same mapArray/indexArray split behind For/Index (flow.ts at 1.9.15).
Repeat skips the data diff altogether: repeat(count, map, { from }) keeps one owner per index in a window, disposes indexes leaving [from, from + count) and creates new ones, and hands each row a plain number (map.ts, flow.ts). RFC 03 positions it for store-backed lists, where "the index is just a stable lookup key; reactivity comes from the store reads" (RFC 03).
NOTE
documentation/proposals/keyed-list-driver.md describes a compiler-stamped list driver that bypasses mapArray. It is headed "PROPOSAL ONLY. Nothing in this document is implemented" (proposal), and the experimental driver it builds on was removed in the 2.0.0 release: "the insert $ll seam stripped", driveList/rowProof deleted (babel-plugin CHANGELOG.md). No $ll, driveList or rowProof remains in any package source at this commit.
Loading, Errored, Reveal
These three are one-line components over signals primitives: createLoadingBoundary(() => props.children, () => props.fallback, { on }), createErrorBoundary(() => props.children, (err, reset) => …) and createRevealOrder (flow.ts, flow.ts, flow.ts). Their semantics — NotReadyError propagation, holds, error status — belong to the graph and are covered in signals: async computations and signals: errors. One rendering detail: the Loading doc comment states that the children "are not re-created; they stay alive behind the fallback" (flow.ts).
Props, children, refs, context, events and lifecycle
| Area | 2.0 mechanism | Change from 1.x |
|---|---|---|
| Props | getters on a plain object; merge(...sources) and omit(props, ...keys) return live views (merge, omit) | mergeProps → merge, where "undefined is treated as a real value (it overrides)"; splitProps → omit, which returns only the rest (MIGRATION.md) |
| Children | props.children is a getter that builds nodes when read; children(fn) resolves it in two lazy memos and adds toArray() (children) | same API; the 2.0 memos are lazy (children at 1.9.15 used eager memos) |
| Refs | ref={el} assigns, ref={fn} calls, ref={[a, b]} flattens and calls each; the callback runs untracked through runRefCallback (ref, runRefCallback); before insertion, so el.isConnected is false (RFC 07) | "ref callbacks are now unowned"; use: directives become ref factories with an owned setup half and an unowned apply half (MIGRATION.md) |
| Context | createContext returns a provider component; its two lazy memos setContext on their first pass, and useContext reads the owner chain (createContext) | <Ctx.Provider value> → <Ctx value>; a default-less context returns T and throws ContextNotFoundError when missing (MIGRATION.md) |
| Events | onX (uppercase after on) only; delegated handlers are stored on the node as _$$click (+ _$$clickData for the [handler, data] form) and served by one listener per name on the render root, which walks from the target up to the root (eventHandler, delegated list); others use addEventListener | delegation moved from document to each render root; lowercase onclick is now an attribute; on:/oncapture: removed, native options go through a ref (MIGRATION.md) |
| Lifecycle | onSettled(fn) runs after the current activity settles and may return a cleanup bound to the owner (onSettled); onCleanup unchanged (onCleanup); effects are split compute/apply (signals) | onMount → onSettled (MIGRATION.md); 1.x onMount was createEffect(() => untrack(fn)) (signal.ts at 1.9.15) |
Event handlers are never wrapped. The eventExpressions fixture assigns each handler once (output), and RFC 08 states it as a rule: "An event handler is bound once, where its element is created, so the expression on onClick={…} […] is not reactive" (RFC 08).
// <button onChange={() => …}> <button onClick={() => …}> <button onClick={[fn, rowId]}>
_el$2.addEventListener("change", () => console.log("bound"));
_el$7._$$click = () => console.log("delegated");
_el$8._$$click = id => console.log("delegated", id);
_el$8._$$clickData = rowId;WARNING
MIGRATION.md says "getOwner() is null inside" a ref callback (MIGRATION.md). The code path read here — ref → runRefCallback → untrack — does not reset the owner; it sets a ref-callback depth that dev builds check, so onCleanup and primitive creation there throw CLEANUP_IN_FORBIDDEN_SCOPE / PRIMITIVE_IN_EFFECT_CALLBACK (runRefCallback, onCleanup, docs). Whether getOwner() literally returns null was not verified.
@solidjs/element shows the props mechanism from the other side, where a host drives a component: customElement(tag, defaults, Comp) turns each declared prop into a signal behind a getter/setter and writes it from the element's property-changed callback (createProps), then renders into the shadow root under a root it disposes on release (withSolid).
What 2.0 renamed or removed for authoring
| 1.x | 2.0 | Source |
|---|---|---|
solid-js/web, /h, /html, /universal | @solidjs/web, @solidjs/h, @solidjs/html, @solidjs/universal | MIGRATION.md |
JSX namespace and jsx-runtime in solid-js | renderer-owned; Element from solid-js for neutral APIs | RFC 09 |
mergeProps / splitProps | merge / omit | MIGRATION.md |
Index | For keyed={false} | RFC 03 |
Suspense / SuspenseList / ErrorBoundary | Loading / Reveal / Errored | RFC 03 |
createDynamic(source, props) | dynamic(source) factory; <Dynamic> kept but deprecated | RFC 03 |
| — | Repeat (new) | RFC 03 |
onMount | onSettled | MIGRATION.md |
Context.Provider | the context is the provider | MIGRATION.md |
use: directives | ref directive factories, ref arrays | RFC 07 |
classList, attr:, bool:, on:, oncapture: | class object/array; standard attribute model; camelCase events + refs | RFC 07 |
/*@once*/ | removed; untrack in JavaScript or a default* DOM prop | MIGRATION.md |
nested createRoot detached | owned by its parent; runWithOwner(null, …) to detach | MIGRATION.md |
Known pain points and limitations
- Destructuring or top-level reads freeze props. The getter only tracks if it is called inside a tracking scope. The docs' pitfall box: "Change the quantity in the parent and the
Avoidversions keep showing the first value" (components-and-jsx.mdx). 2.0 adds the dev warningSTRICT_READ_UNTRACKEDand tells authors, and coding agents by name, not to silence it withuntrack(RFC 08). - The heuristic is syntax, not types. An identifier is static, so
textContent={rowId}is written once even ifrowIdis a getter function, while{rowId}as a child updates becauseinsertcheckstypeofat runtime (fixture,insert). The escape hatch for the other direction is/*@static*/, which survives in both compilers even though/*@once*/was removed from the public model and the migration guide says "do not look for a marker-based replacement" (babel-pluginREADME.md,MIGRATION.md). - Handlers are bound once.
onClick={selected() ? save : cancel}readsselected()at creation; only dev builds warn (RFC 08). - Reading
props.childrentwice builds twice. It is a getter that creates nodes.Repeatreads it once per row because "a second read would build the row's nodes (and run its refs) twice" (#4296,flow.ts); thechildren()helper exists to memoize the read. - Arity carries meaning.
Show/Matchtreat a function child as a callback only ifchild.length > 0(flow.ts);h/htmltreat any zero-arity function prop as a getter, soonClick={() => …}on a component silently becomes a getter (h README). - Grouped effects re-write siblings. A change to any dynamic attribute in a template re-runs its grouped effect, which re-writes stateful properties such as
value; inputs are "not strictly controlled" and the recommended pattern is a draft signal (RFC 07). - Identity keying punishes fresh objects. A refetch that returns new objects for the same records rebuilds every row (
components-and-jsx.mdx); the attribution engine flags it asUNSTABLE_LIST_IDENTITY, whose RFC text suggests<For by="id">— a propFordoes not have at this commit (RFC 08,For). - Spread order is not guaranteed "given independent binding updates" (babel-plugin
README.md), and a props getter "is defined only for a read through its own object": copying its descriptor elsewhere and reading it there is unsupported (merge). - The compiler is coupled to library names. Auto-imported
builtInsand the productionlowerShowpass recognizeShowby import source (lower-show.ts); a user component with the same role gets neither. - Custom renderers are second-class. Only the README documents
@solidjs/universal(solid-docs mentions it only as a moved import path, migration page); it lacks delegation, templates, hydration and compiler-free authoring, and its list diff lags the web one.
Strengths
- No per-component runtime cost. In production a component is one untracked function call; only bindings and control-flow memos exist at runtime.
- Updates touch exactly what changed. A binding re-runs one compute and one targeted write; a list update keeps row owners and moves nodes.
- Control flow is ordinary code.
For,Show,Loadingare a few dozen lines overmapArrayand memos; a host renderer gets them for free. - A small, honest host contract. Twelve node operations, all structural; everything above them is shared.
- Compiled output is readable and testable. Fixture pairs pin the lowering, and two compilers are held to the same corpus.
Weaknesses
- The rules depend on where a read happens, which the source does not show:
props.xin JSX tracks, the same expression one line above does not. - Syntactic heuristics decide static versus dynamic, with an attribute/child asymmetry and a comment-marker escape hatch.
- JavaScript-specific conventions carry meaning: getters, function arity,
typeofchecks on values, proxies for prop views. - The non-DOM path is thin: no delegation, no template cloning, no hydration, no compiler-free authoring, sparse documentation.
- Compiler and library are coupled through auto-imports and the
Showlowering.
Key design decisions and trade-offs
| Decision | Rationale | Trade-off |
|---|---|---|
| Component runs once, untracked, with no instance | Zero overhead per component; reactivity lives in bindings | Top-level reads and destructuring freeze values; needs a dev warning to teach |
| Dynamic props as getters on a plain object | The read happens in the consumer's tracking scope; literals cost nothing | Getter semantics leak (copying descriptors, double reads of children); combining props needs proxy views |
| Syntactic static/dynamic heuristic | Decided at compile time without type information | Identifiers are assumed static; /*@static*/ marker needed for the reverse case |
| One render effect per hole, one grouped effect per template | Few graph nodes per row; diffing inside the apply half | Any attribute change re-runs the group and re-writes stateful properties |
| Conditions memoized to booleans | Branches survive value churn under per-run ownership | Extra memos per conditional; the compiler rewrites user expressions |
Control flow as components over mapArray/memos | One mechanism (ownership per run) disposes everything | Callback shape varies by mode (keyed), detected partly by arity |
| Two-level list reconciliation | Data diff preserves owners; node diff minimizes moves | Two passes and two maps per structural change; keying by identity rebuilds fresh objects |
| Host contract of structural node operations | Any retained tree can host Solid | Everything DOM-specific (events, templates, hydration) must be rebuilt by the host or is absent |
Lessons for a D UI toolkit
The question this survey feeds is what Solid-style authoring would look like over a D, non-DOM toolkit such as sparkles:ui. Two caveats from the signals page carry over: Solid's guarantees assume a retained node tree whose writers are render effects, and sparkles:ui today rebuilds view() → layout() per frame.
| Mechanism | Transfers? | Depends on a JS feature |
|---|---|---|
Component = function called once under untrack, no instance | yes, directly | none |
Binding per hole: effect(compute, apply(value, prev)); grouped per template | yes; maps onto a render-effect queue drained before layout | closures everywhere: every hole is a closure over node handles; in @nogc D each needs an explicit context (struct + function) |
| Props as lazy reads at the consumer | yes, better typed: a props struct whose dynamic fields are Accessor!T makes the static/dynamic split a type fact | getters hide the call, which is the root of the destructuring pitfall; proxies for merge/omit views (D: struct composition or opDispatch at compile time) |
| Static/dynamic decision at compile time | yes, and decidable by type through Design by Introspection instead of syntax | the JSX compiler itself; the arity/typeof conventions of h/html are JS runtime substitutes |
| The universal host contract (12 structural operations) | yes, the most portable piece: a widget-tree backend implements create/insert/remove/sibling/setProperty | none beyond stable node identity and prev-aware setters |
| Two-level list reconciliation (keyed owners, then node moves) | yes; needs a hash map on keys and node identity | GC: removed rows' closures and nodes are reclaimed by the collector; explicit disposal only runs cleanups |
| Control flow as components owning one child scope per memo run | yes; needs the signals owner tree | none |
| Two-phase directives (owned setup, unowned apply), ref arrays | yes | none |
| Context on the owner chain | yes | none |
| Root-owned event delegation | as a pattern: hit-test once at the root, walk up the node parent chain, call a per-node handler slot | the DOM event model (composedPath, stopPropagation) |
| Template cloning | partially: prebuilt static subtrees copied per instance | the DOM's <template>/cloneNode |
Sources
- solidjs/solid at
solid-js@2.0.3·LICENSE - Component model:
component.ts—createComponent·core.ts—observedComponent,createContext,children·store/utils.ts—merge,omit,isStatic·signals.ts—onSettled,onCleanup·core.ts—runRefCallback - Control flow:
flow.ts(For,Repeat,Show,Switch,Match,Errored,Loading,Reveal) ·map.ts—mapArray,updateKeyedRows,repeat· keyed-list driver proposal - Web runtime:
client.ts—render,template,delegateEvents,eventHandler,ref,insert·render.ts—effect,memo·reconcile.ts·constants.ts— delegated events - Universal:
universal.ts·README.md· test renderer - Compiler: babel-plugin
README.md·utils.ts—isDynamic,transformCondition·lower-show.ts·CHANGELOG.md· compilerREADME.md· parity test - Fixtures:
textInterpolation·attributeExpressions·conditionalExpressions·eventExpressions·lowerShow· universalcomponents,attributeExpressions - No-compiler forms:
hyperscript.ts·@solidjs/hREADME ·tagged-jsx.ts·@solidjs/htmlREADME ·@solidjs/element - RFCs and guides: 03 control flow · 07 DOM · 08 dev diagnostics · 09 TypeScript/JSX ·
MIGRATION.md· TSRX frontend notes and specification snapshot - solid-docs at
c32486f: Components and JSX · Migrating from 1.x - 1.x comparison (
solid-js@1.9.15):component.ts·flow.ts·signal.ts—onMount,children - Related: Solid 2.0 signals · Jetpack Compose · Reactive programming survey ·
sparkles:ui