--- title: Streaming SSR description: Stream head tags as async content resolves during server-side rendering navigation.title: Streaming new: true --- A streaming server may send the document shell before all head entries exist. Unhead puts known entries in the shell. It sends later entries with the application stream. The core API accepts a [Web `ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream). ## How It Works 1. **Shell:** Unhead renders the entries available before streaming starts. 2. **Application:** Async work registers another entry with `head.push()`. 3. **Patch:** The server writes that entry as an inline script between chunks. 4. **Hydration:** The client instance takes over the streamed state. ## Where Tags Render `wrapStream()` captures the entries available when it starts. Create the application stream first: ```ts const appStream = renderToWebStream(app) return wrapStream(head, appStream, template) ``` Tags follow three paths: | Registration time | Output | | --- | --- | | before `wrapStream()` starts | initial document shell | | after the shell | inline patch script | | after the shell, when valid in the body | streamed body tag before `
` | Late JSON-LD, `noscript`, and explicit body positions become streamed body tags. Late `bodyOpen` tags move to the body close because the opening body has already left the server. `flushChunk` only changes patch output. `renderStreamEnd()` writes streamed body tags. ::warning Many bots and link previews do not run patch scripts. Register canonical links, robots, descriptions, and Open Graph tags before the shell. Google can read [JSON-LD from the head or body](https://developers.google.com/search/docs/appearance/structured-data/intro-structured-data#supported-formats). :: ## Setup ### Server Use `wrapStream()` to add head updates to the response: ```ts import { createStreamableHead, prepareTemplate, wrapStream } from 'unhead/stream/server' const { head } = createStreamableHead() head.push({ title: 'My App', htmlAttrs: { lang: 'en' } }) const template = prepareTemplate('