---
name: server-components
description: 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.
---
# Writing Solid server components with slots
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.
## Where things go
> **An element lives where the data that creates it lives.**
- Exists because of **server data** (a todo row, a nav link, a search
form the server renders)? It is **server markup**. A mutation on it is a
form `action` — it works without JavaScript, and the router marks a
submission in flight (`aria-busy`) so CSS can show the intent.
- Needs **client behavior or client state** (a handler, an optimistic add,
a modal, a drag ghost, an editor open over a field)? It is a **client
component** placed through a **slot**.
When the client confirms an optimistic entity and the server renders it, the
row _becomes_ server markup; `$key` on the element reconciles the two.
## Slots
```tsx
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: `