# [API](/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.

```typescript
export declare function generate(opts: SsgGenerateOptions): Promise<SsgResult>;
```

| Parameter | Type | Description |
| --- | --- | --- |
| opts | [SsgGenerateOptions](#ssginternaloptions) |  |

**Returns:**

Promise&lt;[SsgResult](#staticgenerateresult)&gt;

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-router/src/ssg/index.ts)

## 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.

```typescript
export declare function runSsg(opts: SsgGenerateOptions): Promise<never>;
```

| Parameter | Type | Description |
| --- | --- | --- |
| opts | [SsgGenerateOptions](#ssginternaloptions) |  |

**Returns:**

Promise&lt;never&gt;

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-router/src/ssg/index.ts)

## SsgInternalOptions

Internal SSG options that include the render function and router config.

```typescript
export interface SsgGenerateOptions extends SsgOptions
```

**Extends:** [SsgOptions](#ssgoptions)

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| qwikRouterConfig |  | QwikRouterConfig | The Qwik Router Config object (default export from `@qwik-router-config`). |
| render |  | Render | SSR render function (default export from `entry.ssr`); worker-only — the main entry omits it. |
| workerFilePath? |  | string \\| URL | _(Optional)_ Path or URL to the worker entry file (`run-ssg-worker.js`); workers are spawned from it. |

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-router/src/ssg/types.ts)

## SsgOptions

```typescript
export interface SsgOptions extends SsgRenderOptions
```

**Extends:** [SsgRenderOptions](#ssgrenderoptions)

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| basePathname? |  | string | _(Optional)_ Defaults to `/` |
| rootDir? |  | string | _(Optional)_ |

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-router/src/ssg/types.ts)

## SsgRenderOptions

```typescript
export interface SsgRenderOptions extends RenderOptions
```

**Extends:** RenderOptions

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| emitData? |  | boolean | _(Optional)_ Set to `false` if the generated per-loader data files should not be written to disk. Defaults to `true`. |
| emitHtml? |  | boolean | _(Optional)_ Set to `false` if the generated static HTML files should not be written to disk. Setting to `false` is useful if the SSG should only write the per-loader data files to disk. Defaults to `true`. |
| exclude? |  | string[] | _(Optional)_ Defines file system routes relative to the source `routes` directory that should not be static generated. Accepts wildcard behavior. This should not include the "base" pathname. `exclude` always takes priority over `include`. |
| include? |  | string[] | _(Optional)_ Defines file system routes relative to the source `routes` directory that should be static generated. Accepts wildcard behavior. This should not include the "base" pathname. If not provided, all routes will be static generated. `exclude` always takes priority over `include`. |
| log? |  | 'debug' \\| 'quiet' | _(Optional)_ Log level. `'quiet'` suppresses per-page output, `'debug'` enables verbose logging. |
| maxTasksPerWorker? |  | number | _(Optional)_ Maximum number of tasks to be running at one time per worker. Defaults to `20`. |
| 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 `origin`, which is a combination of the scheme (protocol) and hostname (domain). For example, `https://qwik.dev` has the protocol `https://` and domain `qwik.dev`. However, the `origin` does not include a `pathname`. The `origin` is used to provide a full URL during Static Site Generation (SSG), and to simulate a complete URL rather than just the `pathname`. For example, in order to render a correct canonical tag URL or URLs within the `sitemap.xml`, the `origin` must be provided too. If the site also starts with a pathname other than `/`, please use the `basePathname` option in the Qwik Router config options. |
| outDir |  | string | File system directory where the static files should be written. |
| sitemapOutFile? |  | string \\| null | _(Optional)_ File system path to write the `sitemap.xml` to. Defaults to `sitemap.xml` and written to the root of the `outDir`. Setting to `null` will prevent the sitemap from being created. |

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-router/src/ssg/types.ts)

## 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.

```typescript
export declare function startWorker(
  opts: Pick<SsgGenerateOptions, "render" | "qwikRouterConfig">,
): Promise<void>;
```

| Parameter | Type | Description |
| --- | --- | --- |
| opts | Pick<[SsgGenerateOptions](#ssginternaloptions), 'render' \\| 'qwikRouterConfig'> | Must include `render` and `qwikRouterConfig` (imported by the worker entry). The remaining serializable options come from `workerData`. |

**Returns:**

Promise&lt;void&gt;

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-router/src/ssg/index.ts)

## StaticGenerateResult

```typescript
export interface SsgResult
```

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| duration |  | number |  |
| errors |  | number |  |
| rendered |  | number |  |
| staticPaths |  | string[] |  |

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-router/src/ssg/types.ts)
