prototype
MAmattpocock/skills336k5,004 new stars in the last 7 days
Rules for writing Solid 2.0 server components ("use server" functions that return a template) and their slots with @solidjs/web. Use when writing or reviewing a server component, deciding what lives on the server versus the client, or wiring a slot.
A Solid server component is a "use server" function that returns a
template; the browser receives its markup and never its code. Anything the
client contributes goes through a slot on the component's props: a
client component the client places at a position in the server's markup.
This guide is the set of rules an author — a person or an agent — needs to
write one correctly the first time. The design record is
documentation/server-components/server-components-principles.md; this
file is the operative subset.
An element lives where the data that creates it lives.
action — it works without JavaScript, and the router marks a
submission in flight (aria-busy) so CSS can show the intent.When the client confirms an optimistic entity and the server renders it, the
row becomes server markup; $key on the element reconciles the two.
import type { Slot } from "@solidjs/web/frames";
interface TodosProps {
pending: Slot; // no props
editor: Slot<{ id: string; title: string }>; // props from the server
}
A slot is placed as an element: <props.pending />,
<props.editor id={t.id} title={t.title} />. The client owns the nodes
between the slot's markers; the server's markup around them stays the
server's.
export async function todoList() {
"use server";
const todos = await db.list();
return (props: TodosProps) => (
<ul>
{todos.map(t => (
<li $key={t.id}>
{t.title}
<props.editor $key={t.id} id={t.id} title={t.title} />
</li>
))}
<props.pending />
</ul>
);
}
The client passes the fill — a component of the slot's props:
<Todos editor={p => <Editor id={p.id} title={p.title} />} pending={() => <For each={adds}>{…}</For>} />
onCleanup) lives as long as the
occurrence. A top-level read is read once, and STRICT_READ_UNTRACKED
names it ("the `editor` template-slot fill").props.status({ … })) evaluates its args eagerly in the server
component's body.$key is optional. Add it when the fill holds its own state (an edit
draft, a signal created inside) that must follow the entity across
refetches and reorders.asyncArg.
<props.status progress={asyncArg(gen.progress)} /> ships the promise or
async iterable; the fill's read settles (suspends until the first value).A handler on a server-rendered element cannot come from the server: a server function never runs in the browser. Pick one:
<form action={…}>; it works before
JavaScript and needs no client code.<props.toggle id={t.id} done={t.completed} />, rendering
the checkbox on the client).onSettled and
finds its target from the event (closest("button.copy-code")). Inside a
live hole this is the shape that keeps the hole streaming: a slot placed
inside a live hole latches it (SSR_LIVE_HOLE_LATCHED, data.cause
"records"). examples/chat's Copy button is this shape.One component can render on both sides. Put $key={props.id} on the
element it renders (morph identity) — the slot's own $key is a different
key for a different job. Do not read document/window during render;
that is the ordinary isomorphic rule.
With @solidjs/vite-plugin, solid({ ssr: true, serverFunctions: { components: true } }) is the turnkey setup (the examples under
examples/todos-server, examples/notes, examples/chat).
MAmattpocock/skills336k5,004 new stars in the last 7 days
AFaffaan-m/ECC314k4,125 new stars in the last 7 days
FIfirecrawl/firecrawl214k5,821 new stars in the last 7 days
ANanthropics/skills203k3,333 new stars in the last 7 days
Set visual direction and typography for UI, avoiding templated defaults.
ANanthropics/skills203k3,333 new stars in the last 7 days
Build complex HTML artifacts with React, Tailwind CSS, state management and routing.
ANanthropics/skills203k3,333 new stars in the last 7 days