Easy Implementation

Next.js Implementation

Implement GEO in Next.js 15 with App Router using route handlers

Why Next.js is Perfect for GEO

Next.js App Router makes GEO implementation straightforward with built-in API routes

Built-in Features:

  • • Route handlers for API endpoints
  • • Automatic static generation
  • • Built-in caching and headers
  • • TypeScript support out of the box
  • • Easy deployment to Vercel

GEO Benefits:

  • • Server-side rendering for better SEO
  • • Static generation for performance
  • • Edge runtime for global distribution
  • • Automatic optimization
  • • Built-in analytics

Step 1: Create AI.txt Endpoint

Set up the AI crawler permissions endpoint

app/.well-known/ai.txt/route.tstypescript⚛️ Next.js
1import { NextResponse } from 'next/server';
2
3export async function GET() {
4 const aiTxt = `# AI.txt for yoursite.com
5# This file specifies which JSON endpoints are accessible to AI crawlers
6
7User-agent: *
8Allow: /ai/faq.json
9Allow: /ai/service.json
10Allow: /ai/summary.json
11
12# Last updated: ${new Date().toISOString().split('T')[0]}`;
13
14 return new NextResponse(aiTxt, {
15 status: 200,
16 headers: {
17 'Content-Type': 'text/plain; charset=utf-8',
18 'Cache-Control': 'public, max-age=86400, stale-while-revalidate=604800',
19 },
20 });
21}

Step 2: Create AI Summary Endpoint

Implement the AI summary endpoint with your site information

app/ai/summary.json/route.tstypescript⚛️ Next.js
1import { NextResponse } from 'next/server';
2
3export async function GET() {
4 const summary = {
5 version: "1.0",
6 lastModified: new Date().toISOString(),
7 summary: "Your Next.js app provides [services] to [audience] with [benefits]. Built with Next.js 15 and App Router for optimal performance and SEO.",
8 keyFeatures: [
9 "Next.js framework",
10 "App Router",
11 "TypeScript support",
12 "Server-side rendering",
13 "Static generation"
14 ],
15 targetAudience: [
16 "Web developers",
17 "Full-stack developers",
18 "React developers"
19 ],
20 primaryUseCases: [
21 "Web applications",
22 "APIs",
23 "Static sites",
24 "E-commerce"
25 ]
26 };
27
28 return NextResponse.json(summary, {
29 status: 200,
30 headers: {
31 'Content-Type': 'application/json',
32 'Cache-Control': 'public, max-age=86400, stale-while-revalidate=604800',
33 },
34 });
35}

Step 3: Create FAQ Endpoint

Add frequently asked questions for AI systems

app/ai/faq.json/route.tstypescript⚛️ Next.js
1import { NextResponse } from 'next/server';
2
3export async function GET() {
4 const faq = {
5 version: "1.0",
6 lastModified: new Date().toISOString(),
7 faqs: [
8 {
9 question: "What is this Next.js app about?",
10 answer: "This is a [service type] built with Next.js that helps [audience] with [benefits]."
11 },
12 {
13 question: "What technologies are used?",
14 answer: "This app is built with Next.js 15, App Router, TypeScript, and modern web standards."
15 },
16 {
17 question: "How can I get started?",
18 answer: "Visit our documentation or contact us for more information about our services."
19 }
20 ]
21 };
22
23 return NextResponse.json(faq, {
24 status: 200,
25 headers: {
26 'Content-Type': 'application/json',
27 'Cache-Control': 'public, max-age=86400, stale-while-revalidate=604800',
28 },
29 });
30}

Step 4: Create Service Endpoint

Define your service capabilities and endpoints

app/ai/service.json/route.tstypescript⚛️ Next.js
1import { NextResponse } from 'next/server';
2
3export async function GET() {
4 const service = {
5 version: "1.0",
6 lastModified: new Date().toISOString(),
7 service: {
8 name: "Your Next.js App",
9 type: "web-application",
10 description: "A modern web application built with Next.js",
11 url: "https://yoursite.com",
12 capabilities: [
13 "Server-side rendering",
14 "Static generation",
15 "API routes",
16 "TypeScript support"
17 ],
18 endpoints: {
19 "home": "/",
20 "about": "/about",
21 "contact": "/contact",
22 "api": "/api"
23 },
24 supportedFrameworks: ["Next.js", "React", "TypeScript"],
25 contact: {
26 "email": "contact@yoursite.com",
27 "documentation": "https://yoursite.com/docs"
28 },
29 pricing: "free",
30 availability: "24/7"
31 }
32 };
33
34 return NextResponse.json(service, {
35 status: 200,
36 headers: {
37 'Content-Type': 'application/json',
38 'Cache-Control': 'public, max-age=86400, stale-while-revalidate=604800',
39 },
40 });
41}

Step 5: Create Robots.txt Endpoint

Set up general crawler permissions and AI crawler access

app/robots.txt/route.tstypescript⚛️ Next.js
1import { NextResponse } from 'next/server';
2
3export async function GET() {
4 const robots = `# Allow legitimate search engines and AI crawlers
5User-agent: Googlebot
6Allow: /
7
8User-agent: Bingbot
9Allow: /
10
11User-agent: Slurp
12Allow: /
13
14User-agent: DuckDuckBot
15Allow: /
16
17User-agent: Baiduspider
18Allow: /
19
20User-agent: YandexBot
21Allow: /
22
23# Allow AI crawlers for GEO content
24User-agent: GPTBot
25Allow: /
26
27User-agent: ChatGPT-User
28Allow: /
29
30User-agent: CCBot
31Allow: /
32
33User-agent: anthropic-ai
34Allow: /
35
36User-agent: Claude-Web
37Allow: /
38
39# Allow social media crawlers
40User-agent: facebookexternalhit
41Allow: /
42
43User-agent: Twitterbot
44Allow: /
45
46User-agent: LinkedInBot
47Allow: /
48
49# Block suspicious bots and scrapers
50User-agent: *
51Disallow: /api/
52Disallow: /_next/
53Disallow: /admin/
54Disallow: /private/
55Disallow: /*.json$
56Disallow: /*?*
57
58# Block common bad bots
59User-agent: AhrefsBot
60Disallow: /
61
62User-agent: MJ12bot
63Disallow: /
64
65User-agent: DotBot
66Disallow: /
67
68User-agent: SemrushBot
69Disallow: /
70
71User-agent: BLEXBot
72Disallow: /
73
74User-agent: DataForSeoBot
75Disallow: /
76
77User-agent: MegaIndex
78Disallow: /
79
80User-agent: PetalBot
81Disallow: /
82
83User-agent: AspiegelBot
84Disallow: /
85
86User-agent: SeoCheckBot
87Disallow: /
88
89User-agent: SeoBot
90Disallow: /
91
92User-agent: SeobilityBot
93Disallow: /
94
95User-agent: SiteAuditBot
96Disallow: /
97
98User-agent: Siteimprove
99Disallow: /
100
101User-agent: SiteLockSpider
102Disallow: /
103
104User-agent: SiteSucker
105Disallow: /
106
107User-agent: Sogou
108Disallow: /
109
110User-agent: spbot
111Disallow: /
112
113User-agent: SurveyBot
114Disallow: /
115
116User-agent: TurnitinBot
117Disallow: /
118
119User-agent: Vagabondo
120Disallow: /
121
122User-agent: VelenPublicWebCrawler
123Disallow: /
124
125User-agent: WebDataStats
126Disallow: /
127
128User-agent: WebEnhancer
129Disallow: /
130
131User-agent: WebStripper
132Disallow: /
133
134User-agent: WebSauger
135Disallow: /
136
137User-agent: WebZIP
138Disallow: /
139
140User-agent: WotBox
141Disallow: /
142
143User-agent: Wprecon
144Disallow: /
145
146User-agent: Xaldon_WebSpider
147Disallow: /
148
149Sitemap: https://yoursite.com/sitemap-llm.xml`;
150
151 return new NextResponse(robots, {
152 status: 200,
153 headers: {
154 'Content-Type': 'text/plain',
155 'Cache-Control': 'public, max-age=86400, stale-while-revalidate=604800',
156 },
157 });
158}

Step 6: Create Sitemap-LLM.xml Endpoint

Create an LLM-optimized sitemap that includes all GEO endpoints

app/sitemap-llm.xml/route.tstypescript⚛️ Next.js
1import { NextResponse } from 'next/server';
2
3export async function GET() {
4 const sitemap = `<?xml version="1.0" encoding="UTF-8"?>
5<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
6 <!-- Main site pages -->
7 <url>
8 <loc>https://yoursite.com/</loc>
9 <lastmod>${new Date().toISOString().split('T')[0]}</lastmod>
10 <changefreq>weekly</changefreq>
11 <priority>1.0</priority>
12 </url>
13
14 <!-- GEO Contract Endpoints -->
15 <url>
16 <loc>https://yoursite.com/.well-known/ai.txt</loc>
17 <lastmod>${new Date().toISOString().split('T')[0]}</lastmod>
18 <changefreq>monthly</changefreq>
19 <priority>0.8</priority>
20 </url>
21 <url>
22 <loc>https://yoursite.com/ai/summary.json</loc>
23 <lastmod>${new Date().toISOString().split('T')[0]}</lastmod>
24 <changefreq>weekly</changefreq>
25 <priority>0.8</priority>
26 </url>
27 <url>
28 <loc>https://yoursite.com/ai/faq.json</loc>
29 <lastmod>${new Date().toISOString().split('T')[0]}</lastmod>
30 <changefreq>monthly</changefreq>
31 <priority>0.7</priority>
32 </url>
33 <url>
34 <loc>https://yoursite.com/ai/service.json</loc>
35 <lastmod>${new Date().toISOString().split('T')[0]}</lastmod>
36 <changefreq>monthly</changefreq>
37 <priority>0.7</priority>
38 </url>
39
40 <!-- Other site pages -->
41 <url>
42 <loc>https://yoursite.com/docs</loc>
43 <lastmod>${new Date().toISOString().split('T')[0]}</lastmod>
44 <changefreq>weekly</changefreq>
45 <priority>0.9</priority>
46 </url>
47</urlset>`;
48
49 return new NextResponse(sitemap, {
50 status: 200,
51 headers: {
52 'Content-Type': 'application/xml',
53 'Cache-Control': 'public, max-age=86400, stale-while-revalidate=604800',
54 },
55 });
56}