Free auditStart free
GuideNext.js · AI discovery

Next.js AI crawlers

Serve crawler-specific robots.txt rules from Next.js, separate search discovery from model training controls, and verify the deployed response.

4 min
read
7
sources
Oct 24, 2026
updated
Scaplet Editorial Team
author
In one line

In the Next.js App Router, return separate crawler rules from app/robots.ts using MetadataRoute.Robots. OpenAI separates OAI-SearchBot search access from GPTBot training use. Google-Extended is a robots token, not a separate request user agent, and does not affect Google Search. Verify production /robots.txt and any CDN or firewall rules.

30-second check

Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?
Summarize this page withChatGPTClaudePerplexityGoogleAI Mode
01Map a policy to the relevant token

Decide which crawler use case you mean

AI bots do not all perform the same job. OpenAI distinguishes OAI-SearchBot, which is used for ChatGPT search discovery, from GPTBot, which may crawl content for training. Google-Extended is a robots.txt product token that governs certain Gemini and Vertex AI uses; Google says it has no separate HTTP request user agent and does not affect Search inclusion or ranking. A single catch-all rule can therefore change more than the use case you intend.
Token

OAI-SearchBot

Documented purpose
OpenAI search crawling for ChatGPT search features
Decision to make
Allow if you want pages shown in ChatGPT search answers. OpenAI says opted-out sites will not be shown in those answers, though they can still appear as navigational links.
Token

GPTBot

Documented purpose
OpenAI crawling for potential training use
Decision to make
Set a training preference independently from search availability.
Token

Googlebot

Documented purpose
Google Search crawling, including eligibility for AI Search features
Decision to make
Keep important public pages accessible if you want them eligible for Google Search.
Token

Google-Extended

Documented purpose
Google control token for certain Gemini and Vertex AI training and grounding uses
Decision to make
Do not treat it as a separate Google crawler or a way to opt out of Search.
Token

ChatGPT-User

Documented purpose
User-triggered page fetches in certain ChatGPT actions
Decision to make
OpenAI says it is not used for automatic crawling, robots.txt rules may not apply because users initiate the actions, and it is not used to decide whether content appears in Search. Use OAI-SearchBot for search opt-outs.
02How it works

Generate rules with the App Router

Next.js supports a generated robots file through the special app/robots.ts route. It is a special Route Handler that is cached by default unless it uses a request-time API or a dynamic config option, and it has been available since Next.js 13.3.0. In a Pages Router app, put a static robots.txt in public/ instead; Next.js documents that folder for robots.txt and errors if a static file has the same name as a file in pages/.
app/robots.ts with independent crawler choices
import type { MetadataRoute } from 'next'

export default function robots(): MetadataRoute.Robots {
  return {
    rules: [
      { userAgent: 'OAI-SearchBot', allow: '/' },
      { userAgent: 'GPTBot', disallow: '/' },
      { userAgent: 'Googlebot', allow: '/' },
      { userAgent: 'Google-Extended', disallow: '/' },
    ],
    sitemap: 'https://www.example.com/sitemap.xml',
  }
}
  1. 01

    Write down the desired outcome

    Decide separately whether to permit Search discovery, model training use, user-triggered fetches, or all crawler access. Align the choice with your content and data policy.

  2. 02

    Add the special file

    In an App Router project, add app/robots.ts and return the MetadataRoute.Robots shape. Use explicit user-agent groups for independent decisions and include the production sitemap URL if appropriate.

  3. 03

    Deploy and inspect the response

    Open /robots.txt on production and verify the exact groups, spelling, paths, and sitemap line. Check whether a CDN, WAF, or proxy also blocks the crawler.

  4. 04

    Test representative routes

    Check a public article, a commercial landing page, and a private or utility route. Confirm the rule is narrow enough to preserve the pages you want discovered.

03Checklist

Interpret crawler access and search outcomes correctly

  1. 01Robots.txt is a public crawl preference, not authentication. Do not expose confidential drafts or customer data and expect a Disallow rule to protect them.
  2. 02A crawl restriction does not itself remove an already-known URL from search. If a public page should be excluded from Google, use the appropriate indexing directive and allow Googlebot to fetch it so the directive is visible.
  3. 03A robots policy does not override network controls. If logs show 403 responses, inspect the WAF, CDN, rate limits, and bot mitigation rules as well as Next.js output.
  4. 04Don't infer citation frequency from requests. Search Console measures Google's indexing and search visibility; referral analytics or a defined prompt sample measure different outcomes.
  5. 05Recheck after changing the hostname, sitemap, route structure, deployment adapter, or middleware. The framework file can be correct while a proxy serves a different response.

OpenAI recommends allowing OAI-SearchBot in robots.txt, and allowing its published IP ranges, to help a site appear in ChatGPT search results. It says it can take about 24 hours after a robots.txt update for its systems to adjust for search results. If a site allows both bots, OpenAI may use results from one crawl for both uses. Google-Extended has separate semantics. Review the latest official crawler lists before adding more user agents; names and use cases can change.

For the framework implementation, see Next.js robots.txt. For Google's token semantics, see Google-Extended and Google AI Overviews.

Sources · 7

Every fact, linked and dated.

Official docs first. The date is when we last opened each page.
  • nextjs.org
  • openai.com
  • google.com
  1. 01Metadata Files: robots.txt | Next.jsnextjs.org · checked 2026-10-24
  2. 02Overview of OpenAI Crawlersdevelopers.openai.com · checked 2026-10-24
  3. 03Google's common crawlers | Google Crawling Infrastructuredevelopers.google.com · checked 2026-10-24
  4. 04AI features and your website | Google Search Centraldevelopers.google.com · checked 2026-10-24
  5. 05Introduction to robots.txt | Google Search Centraldevelopers.google.com · checked 2026-10-24
  6. 06Block Search indexing with noindex | Google Search Centraldevelopers.google.com · checked 2026-10-24
  7. 07Public Folder | Next.js Pages Router Docsnextjs.org · checked 2026-10-24
Questions

Asked a lot.

3 questions people ask next, answered from the sources on this page.

01How do I add AI bots to a Next.js robots.txt?

In the App Router, return separate user-agent groups from app/robots.ts using the MetadataRoute.Robots type, then inspect the deployed /robots.txt.

02Should I block GPTBot but allow OAI-SearchBot?

Yes. OpenAI says each setting is independent: a site can allow OAI-SearchBot to appear in search results while disallowing GPTBot to indicate that crawled content should not be used for training. Verify that your deployed response contains the intended groups.

03Does blocking Google-Extended remove my site from Google Search?

No. Google says Google-Extended does not affect Search inclusion or rankings; Googlebot controls Search crawling.

Free · 2 minutes

Tools point. Agencies advise. This one ships.

Run the free audit, then approve the fixes. Every change can be undone.

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • 0→7 ChatGPT citations in six weeks Paylane