getApp

View as MarkdownOpen in Claude

Get the fully initialized Hono application instance. If the app has not been created yet, this method initializes it with all routes, middleware, health checks, and security headers — the same configuration that serve() would create.

This is primarily used when embedding the agent in a larger Hono application or when deploying to serverless platforms.

Parameters

None.

Returns

Hono — The configured Hono application instance with all agent endpoints registered.

Examples

Embed in existing Hono app

1import { Hono } from 'hono';
2import { AgentBase } from '@signalwire/sdk';
3
4const mainApp = new Hono();
5const agent = new AgentBase({ name: 'assistant', route: '/agent' });
6agent.setPromptText('You are a helpful assistant.');
7
8mainApp.route('/ai', agent.getApp());

Use with a custom server

1import { serve } from '@hono/node-server';
2import { AgentBase } from '@signalwire/sdk';
3
4const agent = new AgentBase({ name: 'assistant', route: '/assistant' });
5agent.setPromptText('You are a helpful assistant.');
6
7const app = agent.getApp();
8serve({ fetch: app.fetch, port: 8080 });