# ToSSGOptions

**Kind:** Interface

**Source:** [`src/helper/ssg/ssg.ts`](https://github.com/honojs/hono/blob/main/src/helper/ssg/ssg.ts#L181)

**Part of:** [Helper](subsystem-src-helper)

`ToSSGOptions` configures static site generation in the SSG helper. It defines the output directory, request and generation hooks, concurrency, extension mappings, and plugins used during generation.

## Properties

| Property | Type |
|---|---|
| `dir` | `string` |
| `beforeRequestHook` | `BeforeRequestHook | BeforeRequestHook[]` |
| `afterResponseHook` | `AfterResponseHook | AfterResponseHook[]` |
| `afterGenerateHook` | `AfterGenerateHook | AfterGenerateHook[]` |
| `concurrency` | `number` |
| `extensionMap` | `Record<string, string>` |
| `plugins` | `SSGPlugin[]` |

## Diagram

```mermaid
graph LR
  Options[ToSSGOptions]
  Options --> Dir[dir]
  Options --> Before[beforeRequestHook]
  Options --> AfterResponse[afterResponseHook]
  Options --> AfterGenerate[afterGenerateHook]
  Options --> Concurrency[concurrency]
  Options --> Extensions[extensionMap]
  Options --> Plugins[plugins]
```

## Usage

```ts
import type { ToSSGOptions } from './ssg'

const options: ToSSGOptions = {
  dir: './dist',
  beforeRequestHook: async () => {
    // Run before an SSG request.
  },
  afterResponseHook: async () => {
    // Run after an SSG response.
  },
  afterGenerateHook: async () => {
    // Run after generated output is written.
  },
  concurrency: 4,
  extensionMap: {
    '.html': '.html',
    '.json': '.json',
  },
  plugins: [],
}
```

## AI Coding Instructions

- Set `dir` to the directory where generated files should be written.
- Accept either a single hook or an array of hooks for each hook field.
- Keep `beforeRequestHook`, `afterResponseHook`, and `afterGenerateHook` aligned with their execution stage.
- Set `extensionMap` entries to map generated source extensions to output extensions.
- Pass SSG integrations through `plugins` as `SSGPlugin` instances.
