# @askrjs/askr/ssg

> Published API exports for @askrjs/askr/ssg.

Source: [https://askrjs.com/docs/reference/api/askr/ssg](https://askrjs.com/docs/reference/api/askr/ssg)

Status: stable. Packages: @askrjs/askr/ssg.

**Published packages are authoritative.** Examples may lag behind a published contract. When guidance differs, verify the exports and TypeScript declarations in your installed package, then file an issue.

## Exports

This entrypoint publishes 16 exports from the declarations shipped by @askrjs/askr.

### `createStaticGen`

```ts
createStaticGen: (options: SSGOptions) => { generate(generateOptions?: SSGGenerateOptions): Promise<SSGResult>; getConfig(): { routeCount: number; outputDir: string; seed: number; concurrency: number; parallelism: number; hasDataOverrides: boolean; assetCount: number; }; getResult(): SSGResult | null; }
```

Create a Static Site Generator

Usage:
```ts
const ssg = createStaticGen({
  registry,
  outputDir: './dist',
  dataOverrides: {
    '/api/posts': { posts: [...] }
  }
});

const result = await ssg.generate();
console.log(`Generated ${result.successful}/${result.totalRoutes} routes`);
```

### `DiscoveredResources`

```ts
DiscoveredResources: any
```

Resource discovery result for a single route

### `DocumentRenderArgs`

```ts
DocumentRenderArgs: any
```

Arguments passed to a {@link DocumentRenderer}: the rendered app HTML and its context.

- `appHtml`: appHtml: string;

- `context`: context: DocumentRenderContext;

### `DocumentRenderContext`

```ts
DocumentRenderContext: any
```

Request/render metadata passed to a {@link DocumentRenderer}.

- `mode`: mode: 'ssr' | 'ssg';

- `url`: url: string;

- `pathname`: pathname: string;

- `search`: search: string;

- `hash`: hash: string;

- `params`: params: Record<string, string>;

- `data`: data?: SSRData;

- `seed`: seed: number;

- `route`: route: DocumentRenderRoute;

- `cspNonce`: cspNonce?: string;

- `styles`: styles?: readonly SSRStyleRegistration[];

### `DocumentRenderer`

```ts
DocumentRenderer: (args: DocumentRenderArgs) => string
```

Wraps rendered app HTML in a full document (`<html>`, `<head>`, etc.) for SSR/SSG output.

### `RouteConfig`

```ts
RouteConfig: any
```

Route config accepted by SSG.

The handler is defined by the route registry and matches router/SSR naming.

- `path`: URL path to generate (e.g., "/blog/post-1", "/")

- `handler`: Route handler compatible with router/SSR

- `props`: Optional base props merged with route params during render

- `namespace`: Optional namespace for router compatibility

- `auth`: Routes with request-auth requirements are runtime-only by default.

- `policies`: Advanced runtime access checks disable prerendering by default

- `params`: Optional path parameter map for template paths like "/blog/{slug}"

- `invalidationKeys`: Optional explicit invalidation keys for incremental generation

- `loader`: Route loader resolved completely before static HTML is rendered.

- `dehydrate`: Select the loader data transported for initial hydration.

- `basePath`: basePath?: string;

- `entries`: SSG entry generator for parameterized routes.

Return one param map per page to be generated.  The path template is
expanded with each map to produce a concrete URL, e.g.:

```ts
route('/posts/{slug}', PostPage, {
  entries: async () => getPosts().map(p => ({ slug: p.slug })),
});
```

### `RouteRenderReason`

```ts
RouteRenderReason: 'full' | 'changed-key' | 'changed-route' | 'new-route' | 'no-keys' | 'unchanged' | 'deleted' | 'runtime-only'
```

Why a route was rendered, skipped, or removed during generation.

### `RouteRenderResult`

```ts
RouteRenderResult: any
```

Result of rendering a single route

- `path`: URL path

- `filePath`: Output file path relative to outputDir

- `html`: Generated HTML content

- `fileSize`: File size in bytes

- `renderDuration`: Render duration in milliseconds

- `resourceCount`: Number of resources discovered and rendered

- `status`: Render or generation status

- `reason`: Why this route was rendered, skipped, or removed

- `written`: Whether the output file was written during this run

- `error`: Error message if rendering failed

- `errorCause`: Original exception preserved for programmatic diagnostics.

- `errorContext`: Route and phase context for the original exception.

### `RouteRenderStatus`

```ts
RouteRenderStatus: 'success' | 'error' | 'skipped' | 'removed'
```

Outcome of generating a single route's static HTML.

### `SSGAssetSource`

```ts
SSGAssetSource: any
```

A static file or directory to copy alongside generated routes.

- `from`: Source file or directory. Relative paths resolve from the current working directory.

- `to`: Destination relative to outputDir. Defaults to the source basename.

### `SSGGenerateOptions`

```ts
SSGGenerateOptions: any
```

Options for a single generation run

- `mode`: Generation mode

- `changedKeys`: Changed invalidation keys for incremental runs

- `changedRoutes`: Changed concrete route paths for incremental runs

- `forceFull`: Force a full rebuild even when incremental mode was requested

### `SSGMetadata`

```ts
SSGMetadata: any
```

Metadata to write to metadata.json

- `generatedAt`: ISO timestamp of generation

- `totalRoutes`: Total number of routes processed

- `successful`: Number of successfully generated routes

- `failed`: Number of failed routes

- `totalDuration`: Total generation duration in milliseconds

- `mode`: Effective generation mode

- `rebuilt`: Number of routes rendered during this run

- `skipped`: Number of current routes skipped as unchanged

- `removed`: Number of stale routes removed from output

- `cacheHits`: Number of rendered routes whose HTML bytes were unchanged

- `invalidatedKeys`: Invalidation keys applied to this run

- `invalidatedRoutes`: Concrete route paths applied to this run

- `routes`: Per-route details

### `SSGMode`

```ts
SSGMode: 'full' | 'incremental'
```

Whether an SSG run rebuilds every route (`full`) or only changed ones (`incremental`).

### `SSGOptions`

```ts
SSGOptions: SSGBaseOptions & {
  /** Explicit route registry captured with `createRouteRegistry()`. */
  registry: RouteRegistry;
}
```

Options for createStaticGen

### `SSGResult`

```ts
SSGResult: any
```

Overall result from SSG generation

- `generatedAt`: ISO timestamp of generation

- `totalRoutes`: Total number of routes processed

- `successful`: Number of successfully generated routes

- `failed`: Number of failed routes

- `totalDuration`: Total generation duration in milliseconds

- `mode`: Effective generation mode

- `rebuilt`: Number of routes rendered during this run

- `skipped`: Number of current routes skipped as unchanged

- `removed`: Number of stale routes removed from output

- `cacheHits`: Number of rendered routes whose HTML bytes were unchanged

- `invalidatedKeys`: Invalidation keys applied to this run

- `invalidatedRoutes`: Concrete route paths applied to this run

- `routes`: Per-route results

### `SSRStyleRegistrationValidation`

```ts
SSRStyleRegistrationValidation: 'warn' | 'error' | 'off'
```

How to react when SSR styles were registered but not included in the rendered document.

## Documentation navigation

[Previous](https://askrjs.com/docs/reference/api/askr/ssr/index.md) | [Next](https://askrjs.com/docs/reference/api/askr/jsx-runtime/index.md)
