Next.js + AI Readiness
Client-side rendering, dynamic routes, and missing metadata make Next.js apps invisible to AI. Here's how to fix it.
Why Next.js Apps Struggle with AI
Next.js is built for speed and developer experience, but many apps default to patterns that are invisible to AI agents. Client-side rendering, dynamic route segments, and SPA-style navigation all create barriers.
CSR pages are invisible
Pages using 'use client' with no server-side rendering appear empty to AI crawlers.
No llms.txt
Next.js doesn't include llms.txt by default — AI models can't get a structured site overview.
Middleware blocks crawlers
Auth middleware, rate limiting, or geo-blocking can inadvertently block AI bot User-Agents.
Missing metadata API usage
Many apps don't use Next.js's built-in metadata API, leaving pages without descriptions.
What w2agent Generates
After auditing your Next.js app, w2agent generates files that drop into your app directory:
public/llms.txtStatic llms.txt served from the public directory — works on any hosting.
public/llms-full.txtFull-content version with markdown from every crawled page.
robots.txt updatesAI crawler rules to add to your app/robots.ts or public/robots.txt.
JSON-LD snippetsSchema.org markup to embed in your layout.tsx or individual pages.
Example: Route handler for dynamic llms.txt
// app/llms.txt/route.ts
import { NextResponse } from "next/server";
import fs from "fs";
import path from "path";
export async function GET() {
const content = fs.readFileSync(
path.join(process.cwd(), "public", "llms.txt"),
"utf-8"
);
return new NextResponse(content, {
headers: { "Content-Type": "text/plain" },
});
}Next.js-Specific Checks
| Check | What It Tests |
|---|---|
| Client-side rendering detection | Flags pages that rely on CSR — invisible to AI crawlers that don't execute JavaScript. |
| llms.txt route handler | Checks if your app serves llms.txt via a route handler or static file in the public directory. |
| Structured data presence | Validates JSON-LD schemas (Article, SoftwareApplication, etc.) rendered in page head or body. |
Step-by-Step Integration
Run the audit
npx w2agent audit https://your-app.comGenerate files
npx w2agent generate https://your-app.comAdd to your app
Copy the generated files into your app/ directory. llms.txt goes to public/llms.txt or can be served via a route handler at app/llms.txt/route.ts.
Deploy
Deploy to Vercel, Netlify, or your preferred hosting. The generated files are static and work with ISR.
MCP Server for Next.js
w2agent can deploy an MCP server that lets AI agents query your Next.js app directly. When content changes, a webhook keeps the index in sync — add a one-line API route to call it on publish.
Deploy from your terminal
npx w2agent mcp deploy https://your-app.comAudit your Next.js site now
Get a free AI readiness score and generate the files your site needs.
Start Free AuditRun from your terminal
npx w2agent audit https://example.comnpx w2agent generate https://example.comnpx w2agent integrate https://example.comnpx w2agent mcp deploy https://example.com