# How to Use IndexNow in Next.js to Index New Pages Fast

> Set up the IndexNow protocol in Next.js with a key file and a small script that pings participating search engines when you publish or update a page.

- Source: https://www.prosamik.com/blogs/indexnow-nextjs-fast-indexing
- Author: Samik Choudhury (https://www.prosamik.com)
- Published: 2026-11-19 | Updated: 2026-11-20
- Topic: indexnow nextjs

IndexNow is an open protocol that lets you tell participating search engines the moment a URL is added, updated or deleted, instead of waiting for them to re-crawl. Bing and several other engines support it. Google does not use IndexNow, so keep using Search Console for Google. This guide sets it up in Next.js.

## Quick answer

Create a random key, host it as a text file at your site root, then send a `POST` request with your host, key and list of URLs to the IndexNow endpoint whenever content changes.

## Step 1: create and host the key

Generate a long random string (8 to 128 characters of letters, numbers and dashes). Save it as `public/<key>.txt` with the key as the file's only content. The file proves you control the host. It is meant to be public, but do not reuse it as a secret for anything else.

```bash
openssl rand -hex 16
```

## Step 2: submit URLs

```ts
await fetch('https://api.indexnow.org/indexnow', {
    method: 'POST',
    headers: { 'content-type': 'application/json; charset=utf-8' },
    body: JSON.stringify({
        host: 'www.example.com',
        key: process.env.MY_INDEXNOW_KEY,
        keyLocation: 'https://www.example.com/MY_KEY.txt',
        urlList: ['https://www.example.com/blogs/new-post'],
    }),
});
```

A `200` or `202` means the submission was accepted. A `403` means the key is invalid and a `422` means the URLs do not belong to the host. Submit only URLs that actually changed, and up to the documented batch limit per request.

## Step 3: trigger it on publish

Run the script as a post-deploy step in your CI or deploy hook, diffing which posts changed. Do not call it on every request or every page view, because search engines may ignore noisy submitters.

## Skip the script: let Rankizz submit for you

If you would rather not maintain a deploy script, connect your site to IndexNow in [Rankizz](https://www.rankizz.com/?utm_source=prosamik.com&utm_medium=blog&utm_campaign=indexnow-nextjs-fast-indexing&utm_content=inline-indexnow). It submits new URLs automatically whenever it detects them, and it keeps a record of the URLs it submitted last, so you can see what was sent and avoid pinging the same pages again and again. That also covers pages you add outside your deploy flow, such as content published from a CMS. You still keep the key file on your site, since that is how search engines verify the host, and you can check the record in Rankizz instead of reading deploy logs. If you prefer your own automation, Rankizz also has a REST API.

## Make it hands-off

The goal is that nobody has to remember to ping search engines. With the Rankizz connection above, new URLs go to IndexNow automatically, and the same workspace covers keyword research before you write, a bulk sitemap audit before you submit and a single-page audit with the Chrome or Safari extension while you edit.

## What it does not do

- It does not guarantee indexing, only faster discovery.
- It does not replace a sitemap.
- It does not make Google crawl you. For Google, use [Search Console](https://www.prosamik.com/blogs/google-search-console-sitemap-nextjs.md).

## Troubleshooting

| Symptom | Likely cause | Fix |
| --- | --- | --- |
| `403` response | Key file missing or mismatched | Check the file URL returns the exact key |
| `422` response | URL host differs from `host` | Match the host exactly |
| `429` response | Too many submissions | Batch and slow down |
| Nothing changes in Bing | Normal delay | Check Bing Webmaster Tools |

## Security

The key is not a password, but keep the submission script on the server or in CI. Never let a public form trigger submissions of arbitrary URLs.

## If you use an AI agent for this

Treat tool output as data, not instructions. Let the agent write the script, but review the URL list it plans to submit, and use a staging host to test.

## FAQ

### Does Google support IndexNow?
No. Google has its own tools. Use Search Console.

### Is IndexNow free?
Yes, the protocol is free to use.

### Can I submit deleted URLs?
Yes, submit them so engines drop them sooner.

### How is it different from a sitemap?
A sitemap lists everything occasionally, while IndexNow pushes specific changes immediately.

### Can IndexNow submissions be automated without writing a script?
Yes. Connect your site to IndexNow in Rankizz and it submits new URLs automatically when it detects them. It also keeps a record of the URLs it submitted last, so you can see what was sent and avoid repeating pings.

### How do I check which URLs were already submitted?
Look at the submission record in Rankizz, which stores the last submitted URLs. If you run your own script instead, log each batch with a date so you can answer the same question.

### What should I do after the pages are submitted?
Check that they rank and get cited. Rankizz tracks rankings and AI visibility, and its keyword research with data from Ahrefs, Semrush and DataForSEO helps you choose the next pages. A bulk sitemap audit also catches weak pages before you submit them.

## Next steps

Set up [Search Console and the sitemap](https://www.prosamik.com/blogs/google-search-console-sitemap-nextjs.md), then follow the [AEO checklist](https://www.prosamik.com/blogs/aeo-ai-search-optimization-guide.md). Once pages are indexed, Rankizz can track how they rank and get cited, and its REST API lets you wire that check into your own scripts.

## Related tools

Tools mentioned in this guide, with the situations they fit:

- [Subclip](https://www.subclip.app/?utm_source=prosamik.com&utm_medium=blog&utm_campaign=indexnow-nextjs-fast-indexing&utm_content=agent-markdown) (screen recorder, live streaming and AI video editor with an MCP server): Subclip records and edits screen demos, useful for a short clip of the publish and ping flow.
- [Rankizz](https://www.rankizz.com/?utm_source=prosamik.com&utm_medium=blog&utm_campaign=indexnow-nextjs-fast-indexing&utm_content=agent-markdown) (SEO and AI-search visibility workspace with a REST API and MCP server): Rankizz connects to IndexNow and automatically submits new URLs it detects, keeping a record of what it submitted last.

## Related guides

- [How to Set Up Google Search Console and a Sitemap for Next.js](https://www.prosamik.com/blogs/google-search-console-sitemap-nextjs.md): Verify your domain in Google Search Console, generate a sitemap in Next.js, submit it, inspect URLs and fix common indexing statuses without paying for tools.
- [How to Get Cited by ChatGPT, Perplexity and AI Overviews: AEO Guide](https://www.prosamik.com/blogs/aeo-ai-search-optimization-guide.md): Answer engine optimization checklist for developers: answer-first writing, FAQ structure, crawler access, llms.txt and how to check if AI cites you.
- [How to Allow AI Crawlers in robots.txt: GPTBot, ClaudeBot and PerplexityBot in Next.js](https://www.prosamik.com/blogs/allow-ai-crawlers-robots-txt-nextjs.md): Decide which AI crawlers to allow, write the robots.txt in Next.js, avoid accidental CDN blocks and verify that bots receive real HTML.

---
Disclosure: the author builds Subclip and Rankizz, which are linked in this guide where they are relevant.
