Framework Guides
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';23export async function GET() {4 const aiTxt = `# AI.txt for yoursite.com5# This file specifies which JSON endpoints are accessible to AI crawlers67User-agent: *8Allow: /ai/faq.json9Allow: /ai/service.json10Allow: /ai/summary.json1112# Last updated: ${new Date().toISOString().split('T')[0]}`;1314 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';23export 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 };2728 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';23export 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 };2223 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';23export 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 };3334 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';23export async function GET() {4 const robots = `# Allow legitimate search engines and AI crawlers5User-agent: Googlebot6Allow: /78User-agent: Bingbot9Allow: /1011User-agent: Slurp12Allow: /1314User-agent: DuckDuckBot15Allow: /1617User-agent: Baiduspider18Allow: /1920User-agent: YandexBot21Allow: /2223# Allow AI crawlers for GEO content24User-agent: GPTBot25Allow: /2627User-agent: ChatGPT-User28Allow: /2930User-agent: CCBot31Allow: /3233User-agent: anthropic-ai34Allow: /3536User-agent: Claude-Web37Allow: /3839# Allow social media crawlers40User-agent: facebookexternalhit41Allow: /4243User-agent: Twitterbot44Allow: /4546User-agent: LinkedInBot47Allow: /4849# Block suspicious bots and scrapers50User-agent: *51Disallow: /api/52Disallow: /_next/53Disallow: /admin/54Disallow: /private/55Disallow: /*.json$56Disallow: /*?*5758# Block common bad bots59User-agent: AhrefsBot60Disallow: /6162User-agent: MJ12bot63Disallow: /6465User-agent: DotBot66Disallow: /6768User-agent: SemrushBot69Disallow: /7071User-agent: BLEXBot72Disallow: /7374User-agent: DataForSeoBot75Disallow: /7677User-agent: MegaIndex78Disallow: /7980User-agent: PetalBot81Disallow: /8283User-agent: AspiegelBot84Disallow: /8586User-agent: SeoCheckBot87Disallow: /8889User-agent: SeoBot90Disallow: /9192User-agent: SeobilityBot93Disallow: /9495User-agent: SiteAuditBot96Disallow: /9798User-agent: Siteimprove99Disallow: /100101User-agent: SiteLockSpider102Disallow: /103104User-agent: SiteSucker105Disallow: /106107User-agent: Sogou108Disallow: /109110User-agent: spbot111Disallow: /112113User-agent: SurveyBot114Disallow: /115116User-agent: TurnitinBot117Disallow: /118119User-agent: Vagabondo120Disallow: /121122User-agent: VelenPublicWebCrawler123Disallow: /124125User-agent: WebDataStats126Disallow: /127128User-agent: WebEnhancer129Disallow: /130131User-agent: WebStripper132Disallow: /133134User-agent: WebSauger135Disallow: /136137User-agent: WebZIP138Disallow: /139140User-agent: WotBox141Disallow: /142143User-agent: Wprecon144Disallow: /145146User-agent: Xaldon_WebSpider147Disallow: /148149Sitemap: https://yoursite.com/sitemap-llm.xml`;150151 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';23export 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>1314 <!-- 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>3940 <!-- 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>`;4849 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}
Next Steps
Complete your GEO implementation and test it