Skip to content

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.

Creating a Config File

  1. Create a .ts, .js, .cjs, or .json file in your project directory, e.g., server-renderer.config.ts.
  2. 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" },
	],
};

Using the Config File

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

Clone this wiki locally