API › @qwik.dev/qwik-router/ssg
generate
Use this function when SSG should be generated from another module, such as a Vite plugin. This function's should be passed the paths of the entry module and Qwik Router Plan.
export declare function generate(opts: SsgGenerateOptions): Promise<SsgResult>;
Parameter | Type | Description |
|---|---|---|
opts |
Returns:
Promise<SsgResult>
runSsg
Run SSG as a standalone process. Writes _static-paths.json to outDir and exits with code 0 on success, 1 on error.
Intended to be called from a generated run-ssg.js wrapper that provides render/config.
export declare function runSsg(opts: SsgGenerateOptions): Promise<never>;
Parameter | Type | Description |
|---|---|---|
opts |
Returns:
Promise<never>
SsgInternalOptions
Internal SSG options that include the render function and router config.
export interface SsgGenerateOptions extends SsgOptions
Extends: SsgOptions
Property | Modifiers | Type | Description |
|---|---|---|---|
qwikRouterConfig | QwikRouterConfig | The Qwik Router Config object (default export from | |
render | Render | The SSR render function (default export from entry.ssr). | |
workerFilePath? | string | URL | (Optional) Path or URL to the worker entry file. Workers are spawned using this file. When run-ssg.js serves as both main and worker entry, this should be |
SsgOptions
export interface SsgOptions extends SsgRenderOptions
Extends: SsgRenderOptions
Property | Modifiers | Type | Description |
|---|---|---|---|
basePathname? | string | (Optional) Defaults to | |
rootDir? | string | (Optional) |
SsgRenderOptions
export interface SsgRenderOptions extends RenderOptions
Extends: RenderOptions
Property | Modifiers | Type | Description |
|---|---|---|---|
emit404Pages? | boolean | (Optional) Set to | |
emitData? | boolean | (Optional) Set to | |
emitHtml? | boolean | (Optional) Set to | |
exclude? | string[] | (Optional) Defines file system routes relative to the source | |
include? | string[] | (Optional) Defines file system routes relative to the source | |
log? | 'debug' | 'quiet' | (Optional) Log level. | |
maxTasksPerWorker? | number | (Optional) Maximum number of tasks to be running at one time per worker. Defaults to | |
maxWorkers? | number | (Optional) Maximum number of workers to use while generating the static pages. Defaults to the number of CPUs available. | |
origin | string | The URL The If the site also starts with a pathname other than | |
outDir | string | File system directory where the static files should be written. | |
sitemapOutFile? | string | null | (Optional) File system path to write the |
startWorker
Bootstrap a worker thread for SSG rendering. Called from the generated run-ssg.js when it detects it's running as a worker thread.
export declare function startWorker(
opts: Pick<SsgGenerateOptions, "render" | "qwikRouterConfig">,
): Promise<void>;
Parameter | Type | Description |
|---|---|---|
opts | Pick<SsgGenerateOptions, 'render' | 'qwikRouterConfig'> | Must include |
Returns:
Promise<void>
StaticGenerateResult
export interface SsgResult
Property | Modifiers | Type | Description |
|---|---|---|---|
duration | number | ||
errors | number | ||
rendered | number | ||
staticPaths | string[] |