SSR Output Target
The ssr output target builds a server-side rendering module for your component library. Given an HTML string or a document, it renders every Stencil component inside it and returns the resulting HTML. Shadow DOM components are rendered as Declarative Shadow DOM by default, and the browser hydrates the markup once your components' JavaScript loads.
The module has no Node.js dependencies, so it runs in Node.js 22+, Deno, Bun, Cloudflare Workers, and other runtimes with web-standard APIs. To render from a non-JavaScript server, see ssr-wasm. To decide between rendering on request and at build time, see Rendering Strategies.
outputTargets: [
{
type: 'ssr',
},
];
Formerly dist-hydrate-script in Stencil v4.
To render every page of a site built with the www output target to HTML at build time, see Prerendering.
Output
dist/ssr
├── index.js
├── index.d.ts
├── ssr-prop.js
└── ssr-prop.d.ts
index.js is the server-side rendering module. ssr-prop.js exports ssrProp(), for framework templates; it runs in the browser too, so it's separate.
Expose both to consumers through your package's exports (generateExportMaps adds them for you):
{
"exports": {
"./ssr": {
"types": "./dist/ssr/index.d.ts",
"import": "./dist/ssr/index.js"
},
"./ssr-prop": {
"types": "./dist/ssr/ssr-prop.d.ts",
"import": "./dist/ssr/ssr-prop.js"
}
}
}