Skip to content

Possible to revalidate sitemap.xml at runtime? #50419

Closed Answered by fabiancdng
fabiancdng asked this question in App Router
Discussion options

You must be logged in to vote

Thanks to @pawelhoros's comment, I checked out the behavior of dynamic sitemaps in the newest Next.js version (14.2.3) and it seems like it is indeed possible to specify a revalidation interval in your sitemap.ts/sitemap.js file now.
You can check out my demo setup here: https://github.com/fabiancdng/nextjs-sitemap-reval-test

If someone is still running into stale sitemaps despite the exported revalidate constant, I recommend upgrading to a newer Next.js version. If you don't want to (or can't) do that, I recommend the solution proposed by @viniciusbitt using route handlers.

Closing this discussion now.
Thanks to everyone who gave their input on this!

Replies: 4 comments 6 replies

Comment options

You must be logged in to vote
6 replies
@FerrariAndrea
Comment options

@lcnogueira
Comment options

@mdrayer
Comment options

@FerrariAndrea
Comment options

@lcnogueira
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by fabiancdng
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
8 participants