---
title: Introduction
description: Agentside serves markdown twins of your pages to AI agents and lets you A/B test what each agent reads.
sidebar:
  order: 0
---

Agentside is a small SDK that answers AI agents with a markdown version of your pages. People keep getting your HTML from the same URL, while agents that ask for markdown or identify themselves by user agent get a clean twin that is cheaper to read and easier to cite.

It is built on [Effect](https://effect.website) and only depends on the fetch-standard `Request` and `Response`, so one config runs in Astro, SvelteKit, Nuxt, Next.js, TanStack Start, Hono, Cloudflare Workers, Bun and anything else that speaks fetch.

## Two ways to get twins

**Describe them as routes.** Map each page path to a string, a function or a remote URL and mount `handle` in front of your app. This fits pages that render on demand, content from a CMS and twins you want to [A/B test](/docs/variants).

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

const twins = agentside({
  routes: {
    "/": "# Acme\n\nAcme sends invoices your customers actually pay.",
    "/pricing": () => renderPricingMarkdown(),
  },
});

const response = await twins.handle(request, () => app.fetch(request));
```

**Convert your built HTML.** If your pages are prerendered, run `prerenderHtml` after the build. It turns each page's `<main>` into markdown, writes `llms.txt` and `llms-full.txt`, and the CDN routes agents to the files. You don't write any markdown.

```ts
import { prerenderHtml, vercelRoutes } from "@usenotra/agentside/build";

const pages = await prerenderHtml({ dir: "dist", siteUrl: "https://acme.dev", llms: { title: "Acme" } });
await Bun.write("vercel.json", JSON.stringify(vercelRoutes(pages.map((page) => page.path)), null, 2));
```

Both serve the same URLs and headers, so you can convert static pages and keep routes for the dynamic ones.

## What you get

- **Content negotiation** for `.md` URLs, `Accept: text/markdown` and known AI agent user agents, with a `Link` header on HTML pages that have a twin.
- **A/B variants per agent** so you can serve a different twin to a vendor, a purpose such as search or a single agent and measure what happens.
- **Error handling that protects agents** from broken twins. A failing variant falls back to control and a failing twin falls back to your HTML page.
- **Caching** with a TTL, request deduplication and no caching of failures.
- **Typed errors** and the raw Effect program through `@usenotra/agentside/effect`.
- **Build-time conversion** of your HTML to markdown with `data-ai-*` attributes for control, plus `llms.txt`, `llms-full.txt` and CDN routes through `@usenotra/agentside/build`.

**[Quickstart](/docs/quickstart)**

Install Agentside and serve your first twin.

**[Static sites](/docs/static-sites)**

Convert your built HTML to markdown and negotiate at the CDN.

**[Framework guides](/docs/frameworks)**

Astro, SvelteKit, Nuxt, Next.js, TanStack Start, Hono, Workers and Bun.

**[Migrating from Dualmark](/docs/migrating-from-dualmark)**

Map your Dualmark config to Agentside routes.

## Benchmarks

Agentside and Dualmark 0.11 run through the same harness. A cached markdown read takes about 2.8 µs against 38 µs, and agent detection about 50 ns against 500 ns. The full table and the harness are in the [benchmarks section of the README](https://github.com/usenotra/agentside#benchmarks).
