Next.jsNext.js

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.

Step-by-step guides

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.txt

Static llms.txt served from the public directory — works on any hosting.

public/llms-full.txt

Full-content version with markdown from every crawled page.

robots.txt updates

AI crawler rules to add to your app/robots.ts or public/robots.txt.

JSON-LD snippets

Schema.org markup to embed in your layout.tsx or individual pages.

Example: Route handler for generated llms.txt (use instead of public/llms.txt)

// app/llms.txt/route.ts
export const dynamic = "force-static";

export async function GET() {
  const content = await buildLlmsTxt(); // your function
  return new Response(content, {
    headers: { "Content-Type": "text/plain; charset=utf-8" },
  });
}

Next.js-Specific Checks

CheckWhat It Tests
Client-side rendering detectionFlags pages that rely on CSR — invisible to AI crawlers that don't execute JavaScript.
llms.txt route handlerChecks if your app serves llms.txt via a route handler or static file in the public directory.
Structured data presenceValidates JSON-LD schemas (Article, SoftwareApplication, etc.) rendered in page head or body.

Step-by-Step Integration

CLI coming soon — run the web audit

1

Generate files

Run the web audit, open the Manual Fixes tab, click Generate, and download the files for your platform.

2

Add 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. Use one, not both: a file in public/ is served instead of a route handler at the same path.

3

Deploy

Deploy to Vercel, Netlify, or your preferred hosting. Files in public/ are static. A route handler is not cached by default in Next.js 15 and later, so add export const dynamic = 'force-static' to build it once.

Agent for Next.js

w2agent can agentize your Next.js app — deploying an agent so AI agents can query it directly. When content changes, a webhook keeps the index in sync — add a one-line API route to call it on publish.

CLI coming soon — run the web audit

Learn more about agent servers →

Score your Next.js site now

Get your free w2agent score and generate the files your site needs.

Get Your Score

CLI coming soon — run the web audit