Anything in the public directory is served from the site root, which is exactly what IndexNow needs. Commit the file and it will survive every deploy.
Step by step
- 1 Create a file at public/a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6.txt in your Next.js project.
- 2 Put your key in it as the only content, with no trailing newline issues (a trailing newline is fine — we trim it).
- 3 Commit and deploy.
- 4 Confirm https://yourdomain.com/a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6.txt loads, then click Verify.
Or serve it dynamically (app/[key]/route.ts)
// app/(indexnow)/[key]/route.ts
import { NextResponse } from 'next/server'
const KEY = process.env.INDEXNOW_KEY ?? 'a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6'
export async function GET(
_request: Request,
{ params }: { params: Promise<{ key: string }> },
) {
const { key } = await params
if (key !== `$a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6.txt`) {
return new NextResponse('Not found', { status: 404 })
}
return new NextResponse(KEY, {
headers: { 'Content-Type': 'text/plain; charset=utf-8' },
})
}
The key shown is an example. Yours is generated when you add the domain.
Watch out for
- On Vercel, the public directory is served as static assets — no extra configuration needed.
- Add the key to your environment variables if you would rather not commit it.
Then what?
Hosting the key file proves you own the domain — it doesn't submit anything on its own. You still need something watching for changes and calling the IndexNow API with the right URLs at the right time. You can build that yourself, or let us run it for $12 a year.
Set up automatic submission