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

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

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

1

Run the audit

npx w2agent audit https://your-app.com
2

Generate files

npx w2agent generate https://your-app.com
3

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.

4

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

Learn more about MCP servers →

Audit your Next.js site now

Get a free AI readiness score and generate the files your site needs.

Start Free Audit

Run from your terminal

npx w2agent audit https://example.com
npx w2agent generate https://example.com
npx w2agent integrate https://example.com
npx w2agent mcp deploy https://example.com
Next.js AI Readiness | w2agent