Deployment blocked: “export const dynamic” not configured on /sitemap.xml with output: export
I’m experiencing a persistent deployment error that’s blocking my project from building, even after reverting to previous commits. Environment:
Framework: Next.js with output: ‘export’
Deployment: Vercel
Build tool: v0.app The Error:
My Setup:
Static sitemap.xml file in /public/sitemap.xml
next.config.js has output: 'export' configured
No dynamic sitemap files exist in /app (confirmed by search)
Using v0.app to generate/manage the project What I’ve Already Tried:
Cleared .next and .vercel directories
Reverted to multiple previous commits - error persists
Verified there are NO files: app/sitemap.ts, app/sitemap.js, app/sitemap.xml/route.ts
v0 AI assistant confirmed no dynamic sitemap generation exists
Added configuration changes suggested by support - didn’t help
Vercel support said to clear cache and redeploy - error still occurs Build Logs Show:
The error references: .next/server/app/sitemap.xml/route.js:5:3 - which is generated automatically during build, not a file I created. The Core Issue:
Next.js is auto-generating a dynamic route handler for /sitemap.xml that conflicts with output: export, but I only have a static sitemap.xml file.
Has anyone encountered this? Any solutions would be greatly appreciated!
Thanks,
Omar
Hi @amatoomar-6963, I wanted to follow up regarding the deployment issue you reported with the “export const dynamic” error on your sitemap.xml. Have you had a chance to find a solution, or do you still require assistance? If you need help, could you provide the following details?
Have you made any recent changes to your next.config.js?
Are there any other routes or configurations in your project that might conflict with static export?
output: ‘export’ is the constraint here. Static export can’t run a dynamic sitemap route at request time, so anything that creates /sitemap.xml as an app route will fight the build mode.
I’d check for these too, not just app/sitemap.ts:
app/sitemap.xml/route.ts
app/**/sitemap.ts
generateSitemaps()
anything v0 added that imports MetadataRoute.Sitemap
If you really only want a static file, keep public/sitemap.xml and make sure there is no app route for sitemap at all. If the sitemap needs live CMS/API data, drop output: ‘export’ and deploy it as a normal Next app instead.
The quickest proof is running a clean local build after deleting .next. If .next/server/app/sitemap.xml/route.js appears again, something in the app tree is still generating that route.
That file normally means Next.js found an App Router sitemap route/metadata file somewhere. A plain static file in public/sitemap.xml should not need an app route generated under .next/server/app/sitemap.xml.
I’d search the whole repo, including src/app if you have one, but excluding generated folders:
If you want to keep output: "export", the simplest setup is:
public/sitemap.xml
and no app/sitemap.ts, no src/app/sitemap.ts, and no app/sitemap.xml/route.ts.
If you do want Next.js to generate the sitemap, it has to be fully build-time/static. It cannot depend on request-time APIs or runtime-only data, because output: "export" has no server route to run after the build.
After removing any app sitemap route, I’d test locally with a clean build:
rm -rf .next out
npm run build
find .next -path "*sitemap.xml*"
If .next/server/app/sitemap.xml/route.js still appears, something in the app tree is still creating the sitemap route. If it does not appear locally but appears on Vercel, then I’d check the deployed branch/commit and whether v0 regenerated the sitemap file in a different path.
The static export docs are useful for the constraint here: