---
title: Hono
seo:
  title: Use Hono with Agentside
description: Serve markdown twins from a Hono middleware, or convert a site generated with Hono's SSG helper.
---

Hono

Agentside runs as Hono middleware and returns a markdown twin when a request asks for one. To see which clients send those requests, read [which AI bots ask for markdown](https://www.usenotra.com/blog/which-ai-bots-ask-for-markdown).

## Install

```bash
npm install @usenotra/agentside
```

## Mount the middleware

Register Agentside as the first middleware. `c.req.raw` is the fetch `Request` and `c.res` holds the response once `next()` has run.

```ts src/index.ts
import { Hono } from "hono";

import { twins } from "./agentside";

const app = new Hono();

app.use("*", (c, next) =>
  twins.handle(c.req.raw, async () => {
    await next();
    return c.res;
  })
);

app.get("/pricing", (c) => c.html(renderPricingPage()));

export default app;
```

```ts src/agentside.ts
import { agentside } from "@usenotra/agentside";

export const twins = agentside({
  routes: {
    "/pricing": () => renderPricingMarkdown(),
  },
  skip: ["/api"],
});
```

When Agentside answers with markdown, the middleware returns that response and the route handler never runs.

## Static output

If you generate a static site with `toSSG` from `hono/ssg`, convert its output folder after it runs.

```ts build.ts
import { toSSG } from "hono/ssg";
import fs from "node:fs/promises";
import { prerenderHtml, vercelRoutes } from "@usenotra/agentside/build";

import app from "./src/index";

await toSSG(app, fs, { dir: "./static" });

const pages = await prerenderHtml({ dir: "static", siteUrl: "https://acme.dev", llms: { title: "Acme" } });

await Bun.write("vercel.json", JSON.stringify(vercelRoutes(pages.map((page) => page.path)), null, 2));
```

See [Static sites](/docs/static-sites) for the conversion rules and the `vercel.json` routes.
