-
-
Notifications
You must be signed in to change notification settings - Fork 274
Server Renderer CLI Config File
David Ortner edited this page Sep 23, 2025
·
8 revisions
The Server Renderer CLI can be configured using a JSON, TypeScript or JavaScript config file. This allows you to set default options and avoid passing them via command line arguments every time you run the CLI.
All available configurations options can be found in the API Documentation for IOptionalServerRendererConfiguration.
- Create a
.ts,.js,.cjs, or.jsonfile in your project directory, e.g.,server-renderer.config.ts. - Add your configuration options to the file. For example, in a Typescript config file:
import type { IOptionalServerRendererConfiguration } from "@happy-dom/server-renderer";
export default <IOptionalServerRendererConfiguration>{
outputDirectory: "./rendered-pages",
urls: [
{
url: "https://example.com/gb/en/",
outputFile: "en-GB.html",
headers: { "X-Test": "true" },
},
{ url: "https://example.com/se/sv/", outputFile: "sv-SE.html" },
],
};You need to pass the path to the config file using the --config or -c CLI argument when running the Server Renderer CLI:
npx @happy-dom/server-renderer --config=./server-renderer.config.ts
Help Packages