[**Documentation**](../../../README)

***

[Documentation](../../../README) / [@zerotal/inertia](../README) / inertiaStream

# Function: inertiaStream()

> **inertiaStream**(`component`, `props?`): `Promise`\<`void`\>

Defined in: [inertia/src/inertia.ts:162](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/inertia/src/inertia.ts#L162)

Render an Inertia page server-side and return a streaming HTML Response.

Splits the HTML template at `<!-- @inertia -->` and writes the server-rendered
component between the prefix and suffix, improving TTFB over `inertia()` since
the browser can start parsing the `<head>` before the component is sent.

Framework-aware: React pages (`.tsx`) stream chunk-by-chunk via
`react-dom/server`'s `renderToReadableStream`; Vue pages (`.vue`) are rendered
to a string via `@inertiajs/vue3`'s SSR mode (head tags injected into
`<head>`) and flushed after the prefix. The component is resolved from
`<cwd>/<inertia.pagesDir>/<component>.{vue,tsx}` (defaults to `resources/js/pages`).

Like [inertia](inertia), this reads the current request from `RequestContext` and
writes the streaming `Response` onto `ctx.response` as a side effect (returns `void`).
Reach it from a controller via `Inertia.stream(...)`.

## Parameters

### component

`string`

Page component name (path relative to the pages dir, no extension), e.g. `"Posts/Show"`.

### props?

`Record`\<`string`, `unknown`\> = `{}`

Props passed to the page; may include prop wrappers (`optional`/`defer`/`merge`/…).

## Returns

`Promise`\<`void`\>

## Throws

[InertiaTemplateNotLoadedError](../classes/InertiaTemplateNotLoadedError) When the HTML template has not been loaded (InertiaProvider not registered).

## Throws

[InvalidComponentError](../classes/InvalidComponentError) When the component name contains path-traversal sequences.

## Example

```ts
async show(http: HttpContext): Promise<void> {
  const post = await Post.findOrFail(http.params.id);
  return Inertia.stream('Posts/Show', { post });
}
```
