# ListOptionsHtmlFormat

**Kind:** Interface

**Source:** [`packages/platform-fastify/interfaces/external/fastify-static-options.interface.ts`](https://github.com/nestjs/nest/blob/master/packages/platform-fastify/interfaces/external/fastify-static-options.interface.ts#L54)

**Part of:** [Platform Fastify](subsystem-packages-platform-fastify)

`ListOptionsHtmlFormat` configures directory listing output in HTML format for Fastify static file serving. It requires `format` to be the literal value `'html'` and provides a `render` function responsible for generating the HTML response content.

## Properties

| Property | Type |
|---|---|
| `format` | `'html'` |
| `render` | `ListRender` |

## Diagram

```mermaid
graph LR
  A[Fastify Static Directory Listing] --> B[ListOptionsHtmlFormat]
  B --> C[format: 'html']
  B --> D[render: ListRender]
  D --> E[Generated HTML Response]
```

## Usage

```ts
import type { ListOptionsHtmlFormat } from './interfaces/external/fastify-static-options.interface';

const directoryListingOptions: ListOptionsHtmlFormat = {
  format: 'html',
  render: (directories, files) => {
    const directoryItems = directories
      .map((directory) => `<li><a href="${directory.href}">${directory.name}/</a></li>`)
      .join('');

    const fileItems = files
      .map((file) => `<li><a href="${file.href}">${file.name}</a></li>`)
      .join('');

    return `
      <!doctype html>
      <html>
        <head><title>Directory listing</title></head>
        <body>
          <h1>Files</h1>
          <ul>${directoryItems}${fileItems}</ul>
        </body>
      </html>
    `;
  },
};
```

## AI Coding Instructions

- Set `format` exactly to `'html'`; other values do not satisfy `ListOptionsHtmlFormat`.
- Implement `render` using the `ListRender` signature expected by the Fastify static integration.
- Escape file names, paths, and other dynamic values before inserting them into generated HTML.
- Return complete, valid HTML when using this format so browsers can render the directory listing correctly.
- Use this interface when configuring HTML directory listings rather than JSON or plain-text listing formats.
