TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/sveltejs/svelte/llms.txt
Use this file to discover all available pages before exploring further.
render() function is used for server-side rendering (SSR) of Svelte components. It takes a component and returns an object with properties for populating HTML on the server.
Import
Signature
Parameters
The Svelte component to render
Configuration options for rendering
Props to pass to the component (excluding
$$slots and $$events)Context map that will be available to the component via
getContext()Prefix for generated IDs to avoid conflicts when rendering multiple instances
Function to transform errors caught by error boundaries before rendering
Return Value
Therender() function returns a RenderOutput object with the following properties:
HTML content that should be inserted into the
<head> element, including component styles and meta tagsHTML content that should be inserted into the
<body> elementAlias for
body. Use body insteadCSP hashes for generated scripts
Array of SHA-256 hash values (format:
sha256-{hash}) for use in CSP script-src directivePromiseLike, so you can await it to handle asynchronous rendering:
Usage
Basic Server-Side Rendering
With Context
With Content Security Policy
Asynchronous Rendering
Error Handling
Notes
- The
render()function is only available when compiling with theserveroption - Generated HTML includes hydration markers for client-side hydration
- The function will throw if CSP options include both
nonceandhash - Component lifecycle hooks like
onMountdo not run during server-side rendering - The
htmlproperty is deprecated; usebodyinstead