You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 9991514
Browse filesBrowse the repository at this point in the historyBrowse files
web: dynamicComponent — component-only sibling of dynamic
Ruling (2026-10-07): `dynamic` stays the combo (component or tag name);
`dynamicComponent` is the component-only sibling; the server-component
docs mount with `dynamicComponent(() => getStory())`. Option (a) of
documentation/plans/frames-b3-sync.md §5.
`dynamic` is factored into a shared core and the tag arm: `dynamicCore(
source, options, tagArm?)` is the whole implementation — the hoisted lazy
factory memo (FLIGHT box, never re-runs for a reset), the per-instance
value memo (async-memo adoption under hydration, the `latest` token, the
`untrack(cached)` warm-up), the three-memo owner shape matching
index.server.ts, the render memo's per-site `createSignal(address, {
ownedWrite })` + `sites` + `untrack(() => binding.component(props,
address))`, kept-resolution delivery (`resolveBinding` / `sameInstance` /
`deliveredAddress`), `static: true`. The only thing the arm decides is
what a string value renders as: `dynamic` passes `staticElement`,
`dynamicComponent` passes nothing. The core never names the element
runtime, so a bundle whose only consumer is `dynamicComponent` sheds
`staticElement`, `createElement`, `spread`, the prop-collection helpers,
the SVG/MathML tables and `getNextElement`.
Server twin in index.server.ts, same factoring (the arm is one
`ssrElement()`), identical hydration-id consumption: the parity spec
renders one page — a client component and a non-live server component
reference — through both entry points and asserts the documents are
byte-identical (same `_hk` keys, same frame markup, same `_fr` record),
inline and streamed; four hydration arms replay the `dynamicComponent`
document through each client entry point (adopted, no request, same
nodes, both slots live).
Type: `dynamicComponent<C extends Component<any>>(source: () => C |
Promise<C> | AsyncIterable<C> | null | undefined | false, options?)` —
no `string` in the union. A server-component reference has no type-level
brand: it is typed as the server function's declared answer, a
`Component<P>` (`LiveSource<Component<P>>` for `live`, an intersection
that is still one), so `Component<any>` covers it. The type test pins a
tag-name source as a compile error here and fine on `dynamic`.
Pins: A7 reset/re-ask (9 arms), C16, C17 parametrized over both entry
points; every other `dynamic` pin unchanged (shared code).
Size (built, vs base d9395e3): page base −7,417 min / −2,152 br →
33,570; page live −7,418 / −2,171 → 37,241; every other scenario 0 / 0.
Floors ratcheted to 33.58 / 37.26 KB (measured + 10 B at the 0.01 KB
step). The edited-dist model said −2,158 / −2,237 before the source was
written.
Fixtures (sc-base-app, sc-live-app) and the server-component docs' mount
examples switched to `dynamicComponent`; `dynamic`'s docs carry a
one-line pointer.
Public API: new export `dynamicComponent` on `@solidjs/web` (client and
server entries). `dynamic` unchanged.
Co-authored-by: Claude via Cursor <[email protected]>
Add `dynamicComponent`, the component-only sibling of `dynamic` (client and server entries). Same contract, semantics and hydration shape as `dynamic` — the two share one implementation — but its source type excludes tag names, and it never references the element runtime: `dynamic` must be able to render a tag, so one `dynamic` on a page retains `createElement`, `spread`, the prop-collection helpers and the SVG/MathML tables for everyone; `dynamicComponent` never does. It is the documented way to mount a server component (`dynamicComponent(() => getStory(id))`); a server-component page mounted through it sheds ≈ 2.2 KB brotli. `dynamic` is unchanged.
- The source evaluation is shared across all mounted instances of the returned component, so using one `dynamic(...)` in many places doesn't duplicate work.
231
+
- Because a source may answer with a tag name, one `dynamic` on a page retains the element runtime (`spread`, the attribute helpers, the namespace tables) for everyone; `dynamicComponent(source)` is the same primitive for a source that only ever answers with a component — a server component mount ([RFC 11](11-server-components.md#using-one)) — and never does.
The client's binding reconnects on death through `live`'s loop; the document render takes first values from the component's sources and hands off (the brand on the component marks the frame's scope); hydration adopts the document's markup and the loop reconnects from there. How frames make the resume _quiet_ — a stable binding identity per address, conditional re-emission by hole — is frames' business, recorded in `documentation/server-components/server-components-principles.md` §9.5. What is RFC-10-level is that liveness has one declaration, one loop, and one status surface across both tiers.
Copy file name to clipboardExpand all lines: documentation/solid-2.0/11-server-components.md
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@
6
6
7
7
## Summary
8
8
9
-
A **server component is a function returned from a server function** — there is no new component API, no new directive, and no `"use client"`. The server function’s _arguments_ are the server’s inputs (ids, filters); the returned component’s _props_ are client positions (**slots**) the server marks but never renders. On the client, `dynamic` is the entire consumption surface: a server-function call that resolves to a frame stream produces a **stable per-call component** — one boundary per (function, arguments), the same per-args rule a query cache keys values by — so refetches of the same call never remount: server content **morphs in place** underneath and client state inside the boundary (focus, inputs, toggles, video) survives server updates. A call with different arguments resolves its own boundary; the site swaps to it, re-materialized instantly from retained state when that call has shown before.
9
+
A **server component is a function returned from a server function** — there is no new component API, no new directive, and no `"use client"`. The server function’s _arguments_ are the server’s inputs (ids, filters); the returned component’s _props_ are client positions (**slots**) the server marks but never renders. On the client, `dynamicComponent` — `dynamic`'s component-only form — is the entire consumption surface: a server-function call that resolves to a frame stream produces a **stable per-call component** — one boundary per (function, arguments), the same per-args rule a query cache keys values by — so refetches of the same call never remount: server content **morphs in place** underneath and client state inside the boundary (focus, inputs, toggles, video) survives server updates. A call with different arguments resolves its own boundary; the site swaps to it, re-materialized instantly from retained state when that call has shown before.
10
10
11
11
The governing invariant is **single-copy**: server content travels as HTML, values the client needs travel as data records, and nothing travels as both. The acceptance test is literal — view-source the page or a navigation response and search for any piece of content; it appears exactly once.
12
12
@@ -64,7 +64,7 @@ A complete working setup (no Vite, no metaframework) is `examples/hackernews`; i
64
64
## Motivation
65
65
66
66
-**Islands fall apart on navigation; RSC ships everything twice.** Islands architectures give a lean initial page but degenerate to full-page loads or bespoke protocols when you navigate. RSC-style server components keep rich composition but serialize the rendered tree alongside the HTML — every piece of server content pays twice. This design — _lakes, not islands_ — keeps one copy: the server owns and streams content, the client owns islands of interactivity **inside** it, and neither re-sends what the other has.
67
-
-**No new API surface.** Every prior server-components design grew a parallel component model. Here the entire client surface is `dynamic` + server functions (RFC 10) plus one `installServerComponents()` call. Boundary identity is **derived, never declared** — the call’s intrinsic (function, arguments) address keys the boundary, mirroring a data layer’s cache keys by construction, so panes over different calls are independent with nothing annotated and multi-instance mounting fans one stream out to every mounted frame.
67
+
-**No new API surface.** Every prior server-components design grew a parallel component model. Here the entire client surface is `dynamicComponent` + server functions (RFC 10) plus one `installServerComponents()` call. Boundary identity is **derived, never declared** — the call’s intrinsic (function, arguments) address keys the boundary, mirroring a data layer’s cache keys by construction, so panes over different calls are independent with nothing annotated and multi-instance mounting fans one stream out to every mounted frame.
68
68
-**Client state must survive server updates.** The failure mode that kills server-driven UIs is the refetch that blows away a half-typed reply. Policy here is structural: refetching into the same boundary morphs server content in place; teardown is disposal, never a version bump.
69
69
70
70
## Detailed design
@@ -102,7 +102,7 @@ async function getStory(id: number) {
102
102
103
103
```tsx
104
104
function StoryPage(props) {
105
-
const Story =dynamic(() =>getStory(props.storyId));
105
+
const Story =dynamicComponent(() =>getStory(props.storyId));
Navigation is a prop change: the tracked source re-calls the server function. A same-arguments refetch resolves the _same_ component reference (equals-gated — `dynamic` never remounts) and the stream morphs the boundary; a new `storyId` resolves that story’s own boundary and the site swaps to it — instantly, from retained content, when the story has shown before. Client-only state never reaches the server. State _inside_ a boundary belongs to its call (`CollapsibleComment`’s toggles reset per story — story 1’s collapse state never bleeds into story 2), while state _outside_ the boundary (`StoryPage`’s own signals) survives every navigation. First load composes with `<Loading>`; refetches don’t re-fallback.
114
+
`dynamicComponent` is `dynamic` for a source that only ever answers with a component ([RFC 03](03-control-flow.md#dynamic-components-the-dynamic-factory)): the same contract and the same implementation, minus the tag arm — `dynamic` has to be able to render a tag name, so one `dynamic` on a page retains the element runtime (`spread` and the attribute helpers) for everyone; a server-component page that mounts with `dynamicComponent` never pays for it.
115
+
116
+
Navigation is a prop change: the tracked source re-calls the server function. A same-arguments refetch resolves the _same_ component reference (equals-gated — `dynamicComponent` never remounts) and the stream morphs the boundary; a new `storyId` resolves that story’s own boundary and the site swaps to it — instantly, from retained content, when the story has shown before. Client-only state never reaches the server. State _inside_ a boundary belongs to its call (`CollapsibleComment`’s toggles reset per story — story 1’s collapse state never bleeds into story 2), while state _outside_ the boundary (`StoryPage`’s own signals) survives every navigation. First load composes with `<Loading>`; refetches don’t re-fallback.
0 commit comments