| title | createHandler | ||||||
|---|---|---|---|---|---|---|---|
| use_cases | ssr mode configuration, server startup, streaming setup, async rendering, performance tuning | ||||||
| tags |
|
||||||
| version | 1.0 | ||||||
| description | Configure server-side rendering modes in SolidStart. Choose between sync, async, or streaming SSR for optimal performance and UX. |
The createHandler is used to start the server in entry-server.tsx.
It takes a function that returns a static document (often created with <StartServer>), renders, and serves it.
:::note To fully understand how to leverage different rendering modes, please refer to the Rendering Modes page. :::
A createHandler is essential to every SolidStart app.
To fallback the rendering mode to the app.config.ts definition (or the default "stream" mode), you can use the createHandler without any options.
import { createHandler, StartServer } from "@solidjs/start/server";
export default createHandler(() => (
<StartServer document={...}
/>
));It is also possible to override the rendering mode for a specific route.
type RenderingModes = "stream" | "async" | "sync";
function createHandler(
handler: () => (document: any, options?: any) => void,
options?:
| { mode?: RenderingModes }
| ((event: RequestEvent) => { mode: RenderingModes })
| undefined
): (event: RequestEvent) => Response;