***

title: serveStaticFiles
slug: /reference/typescript/agents/agent-server/static-files
description: Serve static files from a directory alongside agent routes.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

Serve static files (HTML, CSS, JS, images) from a local directory. Includes path
traversal protection, MIME type detection, and security headers
(`Cache-Control`, `X-Content-Type-Options`).

This method is useful for serving a web frontend alongside your agents -- for example,
an admin dashboard or a configuration UI.

## **Parameters**

<ParamField path="directory" type="string" required={true} toc={true}>
  Path to the directory containing static files. Can be absolute or relative
  (resolved via `path.resolve()` at registration time).
</ParamField>

<ParamField path="route" type="string" default="/static" toc={true}>
  URL path prefix for static files.
</ParamField>

## **Returns**

`void`

## **Example**

```typescript {8}
import { AgentBase, AgentServer } from '@signalwire/sdk';

const support = new AgentBase({ name: 'support', route: '/support' });
support.setPromptText('You are a helpful assistant.');

const server = new AgentServer({ port: 3000 });
server.register(support);
server.serveStaticFiles('./web', '/static');
await server.run();
```

With this configuration:

| Request Path        | Served By                   |
| ------------------- | --------------------------- |
| `/support`          | SupportAgent                |
| `/support/swaig`    | SupportAgent SWAIG endpoint |
| `/static/style.css` | `./web/style.css`           |
| `/static/logo.png`  | `./web/logo.png`            |

<Warning>
  Path traversal attempts (e.g., `/../etc/passwd`) are blocked. The resolved file path
  must remain within the configured static directory.
</Warning>