> This page is for Server SDKs.

> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes.

# mount

> Serve another Hono app or fetch handler alongside the agent's own routes.

[ref-agentbase]: /docs/server-sdks/reference/typescript/agents/agent-base

[get-app]: /docs/server-sdks/reference/typescript/agents/agent-base/get-app

[chat-gateway]: /docs/server-sdks/reference/typescript/agents/chat-gateway

Mount another Hono app, or a fetch handler, alongside this agent's routes. Use
it instead of adding routes to the app from [`getApp()`][get-app] by hand: the
agent rebuilds its app when its routes change (when you register a routing
callback, for example), and a mount is replayed on every build.

A mounted app answers its own CORS preflights, since the agent's CORS and CSRF
middleware don't apply to it. It also sets its own security headers and isn't
behind the agent's basic auth. Mount before calling `serve()`.

## Parameters

**`appOrRouter`** `Hono | ((req: Request) => Response | Promise<Response>)` — required

A Hono app, whose routes are added under `prefix`, or a fetch handler, which is
mounted at `prefix` and doesn't see it.

---

**`opts`** `{ prefix?: string; name?: string }`

Mount options.

---

**`opts.prefix`** `string`

Path to mount at, from the host root. A trailing slash is dropped. Defaults to
the root.

---

**`opts.name`** `string`

Accepted so code written for the Python SDK works. It has no effect.

---

## Returns

[`AgentBase`][ref-agentbase] -- Returns `this` for method chaining.

## Example

```typescript {10}
import { AgentBase, AIChatClient, ChatGateway } from '@signalwire/sdk';

const agent = new AgentBase({ name: 'dispatch', route: '/dispatch' });
const gateway = new ChatGateway({
  client: new AIChatClient(),
  configUrl: 'https://bayview-taxi.example.com/dispatch',
  key: '<YOUR_PUBLISHABLE_KEY>',
});

agent.mount(gateway.router(), { prefix: '/chat' });
await agent.serve();
```

See [`ChatGateway`][chat-gateway] for what the mounted router serves.