IndexNow with Next.js
Publish an IndexNow key in Next.js and submit changed URLs from a trusted server-side deploy hook.
Updated September 2, 2026
Publish the key
Place KEY.txt in public/ so the deployed site serves it from the hostname root. Keep the submission secret in server-only environment configuration, not client bundles.
Submit from trusted code
await fetch('https://api.indexnow.org/indexnow', {
method: 'POST',
headers: { 'Content-Type': 'application/json; charset=utf-8' },
body: JSON.stringify({ host, key, keyLocation, urlList }),
});Deployment workflow
- Calculate changes
- Compare the previous and current sitemap or use CMS webhook payloads.
- Group by host
- Build one payload for each exact hostname.
- Log safely
- Record status and counts, never the key or private draft URLs.