Integration · Next.js
AHTML for Next.js — drop-in agent endpoints
Install @ahtmljs/next and your existing Next.js 14/15 App Router app emits MCP, OpenAPI, JSON-LD, and llms.txt automatically. Three route handlers, three minutes, zero migration.
Step 1 · Install
npm install @ahtmljs/next @ahtmljs/schemaStep 2 · Wire it up
// app/.well-known/ahtml.json/route.ts
import { createManifestRoute } from '@ahtmljs/next/manifest';
import { ahtmlConfig } from '@/lib/ahtml-config';
export const { GET } = createManifestRoute(ahtmlConfig);
// app/ahtml/[[...path]]/route.ts
import { createSnapshotRoute } from '@ahtmljs/next/snapshot';
import { buildSnapshot } from '@/lib/snapshots';
export const { GET } = createSnapshotRoute(buildSnapshot);
// app/llms.txt/route.ts
import { createLlmsTxtRoute } from '@ahtmljs/next/llms-txt';
import { ahtmlConfig } from '@/lib/ahtml-config';
export const { GET } = createLlmsTxtRoute(() => ({ /* ... */ }), ahtmlConfig);Step 3 · Verify
Deploy. Then:
curl https://your-site.com/.well-known/ahtml.json
curl https://your-site.com/ahtml
curl https://your-site.com/llms.txtNotes for Next.js
- Works with App Router and Pages Router (App Router preferred).
- Edge runtime compatible.
- Auto-extracts from existing schema.org JSON-LD on most Shopify/WordPress storefronts.
- This very site (ahtml.dev) dogfoods @ahtmljs/next — view /ahtml or /llms.txt to see live output.