Skip to content

Next.js

Install the plugin:

Terminal window
npm install @aeorank/next

Create an AEO config file:

aeo.config.ts
import type { AeorankNextConfig } from "@aeorank/next";
export const aeoConfig: AeorankNextConfig = {
siteName: "My Site",
siteUrl: "https://example.com",
description: "A description of your site for AI crawlers.",
organization: {
name: "My Company",
url: "https://example.com",
},
faq: [
{ question: "What does your product do?", answer: "It helps you..." },
],
};

Generate files into public/ at build time:

scripts/generate-aeo.ts
import { generateAeoFiles } from "@aeorank/next";
import { aeoConfig } from "../aeo.config";
generateAeoFiles(aeoConfig);
console.log("AEO files generated.");

Add to your build script:

package.json
{
"scripts": {
"build": "tsx scripts/generate-aeo.ts && next build"
}
}

Serve files on-demand using route handlers:

app/llms.txt/route.ts
import { serveAeoFile } from "@aeorank/next";
import { aeoConfig } from "../../aeo.config";
export const GET = serveAeoFile("llms.txt", aeoConfig);

Repeat for each file:

  • app/llms-full.txt/route.ts
  • app/CLAUDE.md/route.ts
  • app/schema.json/route.ts
  • app/robots-patch.txt/route.ts
  • app/faq-blocks.html/route.ts
  • app/citation-anchors.html/route.ts
  • app/sitemap-ai.xml/route.ts

Use withAeorank in your Next.js config to set correct headers:

next.config.ts
import { withAeorank } from "@aeorank/next";
import { aeoConfig } from "./aeo.config";
const aeorank = withAeorank(aeoConfig);
export default aeorank({
// your Next.js config
});

All 8 AEO files are served at your site root: /llms.txt, /llms-full.txt, /CLAUDE.md, /schema.json, /robots-patch.txt, /faq-blocks.html, /citation-anchors.html, /sitemap-ai.xml.