NEXT.JS & REACT AEO PLAYBOOK

Next.js AI Visibility: Break the JavaScript Wall

AI search bots do not execute JavaScript like Chrome does during real-time retrieval. Learn how to architect your Next.js App Router components, streaming SSR, and metadata APIs so ChatGPT, Perplexity, and Claude ingest pure server-rendered truth.

The 3 Critical Traps in Next.js Apps

01

Accidental 'use client' at Route Roots (The JS Wall)

Placing 'use client' at the top of your page file turns the entire subtree into Client-Side Rendering (CSR). When an AI search engine fetches your URL with a raw HTTP GET request, it receives an empty <div id="__next"> shell. AI crawlers do not wait for React hydration bundles.

// Correct App Router Architecture
// page.tsx (Server Component by default — renders full HTML payload)
import InteractiveWidget from './Widget'; // Client Component boundary pushed to leaf

export default async function ProductPage() {
  const data = await fetchContent();
  return (
    <article>
      <h1>{data.title}</h1> {/* Raw HTML immediately readable by GPTBot */}
      <p>{data.summary}</p>
      <InteractiveWidget />
    </article>
  );
}
02

Native app/robots.ts Configuration

Next.js has first-class support for programmatic robots.ts generation. Make sure you don't use a catch-all block that accidentally excludes AI user-agents.

// app/robots.ts

import { MetadataRoute } from 'next';

export default function robots(): MetadataRoute.Robots {
  return {
    rules: [
      { userAgent: '*', allow: '/' },
      { userAgent: ['GPTBot', 'OAI-SearchBot', 'PerplexityBot', 'ClaudeBot'], allow: '/' }
    ],
    sitemap: 'https://yourdomain.com/sitemap.xml',
  };
}
03

Programmatic /llms.txt via Route Handler

Serve a real-time, clean markdown index of your documentation or product catalog using a Next.js App Router Route Handler:

// app/llms.txt/route.ts

export async function GET() {
  const content = `# Your Project\n\n> Core proposition\n\n## Documentation\n- [API](/docs/api)`;
  return new Response(content, {
    headers: { 'Content-Type': 'text/plain; charset=utf-8' }
  });
}

Frequently Asked Questions

Why do AI search crawlers see a blank page on Next.js sites?

Unlike human browsers running Chromium, AI crawlers (like GPTBot, ClaudeBot, and PerplexityBot) perform lightweight HTTP requests without waiting for client-side JavaScript execution. When a Next.js route has 'use client' at its root, the initial HTML shell contains only an empty container, completely concealing your text and data from AI indexing models.

How do I configure robots.ts for AI bots in Next.js 14 and 15?

In Next.js App Router, create an app/robots.ts file using MetadataRoute.Robots. Explicitly define an allow rule for AI agents: ['GPTBot', 'OAI-SearchBot', 'PerplexityBot', 'ClaudeBot'].

How do I serve an llms.txt file in Next.js?

Create a route handler at app/llms.txt/route.ts that exports an async function GET() returning plain text markdown with Content-Type: text/plain; charset=utf-8.

Audit Your Next.js App for AI Search

Verify live server rendering byte ratios, crawlability across 12 AI bots, and test whether LLMs cite your tech stack accurately.

Order Next.js AEO Diagnosis ($49) →