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

***

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

# Class: SsrHandler

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

POST /__ssr — Inertia server-side rendering endpoint.

Accepts the Inertia SSR wire format: { component, props, url }
Returns { body, head } — the rendered HTML string and any head injections.

The component is resolved from <cwd>/<pagesDir>/<component>.{vue,tsx}
(pagesDir defaults to the configured `inertia.pagesDir`, i.e. resources/js/pages)
and rendered with the matching framework runtime — Vue (`@inertiajs/vue3` +
`vue/server-renderer`) for `.vue` files, React (`react-dom/server`) for `.tsx`.

App authors never instantiate this directly — `InertiaProvider` registers the
route when SSR is enabled. Turn it on by setting `ssr: true` in `config/inertia.ts`,
and install the server renderer for the framework(s) in use.

## Example

```ts
// config/inertia.ts
export default InertiaConfig({ ssr: true }); // registers POST /__ssr
```

## Constructors

### Constructor

> **new SsrHandler**(`options?`): `SsrHandler`

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

#### Parameters

##### options?

`pagesDir` overrides where page components are resolved from; defaults to `<cwd>/<inertia.pagesDir>`.

###### pagesDir?

`string`

#### Returns

`SsrHandler`

## Methods

### isAuthorized()

> `static` **isAuthorized**(`http`): `boolean`

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

Whether this request may reach the SSR renderer.

Two ways in, and nothing else:
- the peer is on loopback — the normal case, where the SSR client is the app's own
  Node/Bun renderer talking to itself;
- the request carries SSR\_SECRET\_HEADER matching `inertia.ssrSecret`, for a
  renderer running on another host.

Everyone else gets a 404 rather than a 403, because whether this route exists is not
information a stranger needs. Without the check the endpoint was unauthenticated,
unthrottled, and cheap CPU amplification for anyone who found it.

#### Parameters

##### http

[`HttpContext`](../../core/index/classes/HttpContext)

The request context.

#### Returns

`boolean`

`true` when the request is permitted.
