vercel/next.js · error · Error

Error: you provided query values for ${path} which is an au

Error message

Error: you provided query values for ${path} which is an auto-exported page. These can not be applied since the page can no longer be re-rendered on the server. To disable auto-export for this page add `getInitialProps`

What it means

Thrown when a Pages Router page is auto-exported (purely static: no getInitialProps, no getStaticProps, Component is a static HTML string) but the export attempt carries original query string values. Because an auto-exported page is prerendered once and shipped as static HTML, server-side re-render with query params is impossible, so applying query values would silently drop them. Next.js surfaces this so the developer opts into data fetching explicitly.

Source

Thrown at packages/next/src/export/routes/pages.ts:82

    ...params,
  }

  if (components.getStaticProps && !htmlFilepath.endsWith('.html')) {
    // make sure it ends with .html if the name contains a dot
    htmlFilepath += '.html'
    htmlFilename += '.html'
  }

  let renderResult: RenderResult | undefined

  if (typeof components.Component === 'string') {
    renderResult = RenderResult.fromStatic(
      components.Component,
      HTML_CONTENT_TYPE_HEADER
    )

    if (hasOrigQueryValues) {
      throw new Error(
        `\nError: you provided query values for ${path} which is an auto-exported page. These can not be applied since the page can no longer be re-rendered on the server. To disable auto-export for this page add \`getInitialProps\`\n`
      )
    }
  } else {
    /**
     * This sets environment variable to be used at the time of SSR by head.tsx.
     * Using this from process.env allows targeting SSR by calling
     * `process.env.__NEXT_OPTIMIZE_CSS`.
     */
    if (renderOpts.optimizeCss) {
      process.env.__NEXT_OPTIMIZE_CSS = JSON.stringify(true)
    }
    try {
      renderResult = await lazyRenderPagesPage(
        req,
        res,
        page,
        searchAndDynamicParams,

View on GitHub (pinned to 0ae8c72462)

Solutions

  1. Add a getInitialProps (or getStaticProps) to the page so it becomes server-rendered and can legitimately consume query params.
  2. Strip query parameters from the exportPathMap entries so the static page is exported for the bare pathname only.
  3. If the page is meant to read query at runtime, convert it to use getServerSideProps (and drop output:'export').
  4. Re-evaluate whether the params belong in the path (dynamic route) rather than the query string.

Example fix

// before — pages/search.js (auto-exported, no data fns)
export default function Search() { return <SearchClient /> }
// exportPathMap injects ?q=foo -> error
// after — opt out of auto-export
Search.getInitialProps = (ctx) => {
  return { query: ctx.query.q || '' }
}
Defensive patterns

Strategy: validation

Validate before calling

// If using exportPathMap, strip query params for auto-exported (no-data-fn) pages
function sanitizeExportMap(exportMap: Record<string, { query?: object; page: string }>, dataFns: Set<string>) {
  for (const [path, entry] of Object.entries(exportMap)) {
    if (entry.query && !dataFns.has(entry.page)) {
      delete entry.query // auto-exported page cannot take query
    }
  }
}

Type guard

function pageAcceptsQuery(mod: any): boolean {
  return Boolean(mod.getInitialProps || mod.getStaticProps || mod.getServerSideProps)
}

Try / catch

// Build-time; surface clearly in CI logs
try { await exec('next build') }
catch (e) {
  if (/auto-exported page/.test(e.message)) console.error('Strip query params from exportPathMap or add getInitialProps')
  throw e
}

Prevention

When it happens

Trigger: An exportPathMap (or programmatic export) maps a URL with query params to a page that has no getInitialProps/getStaticProps/getServerSideProps. The export worker sees hasOrigQueryValues === true on a string-typed Component and aborts.

Common situations: Using a custom exportPathMap that appends ?query=... entries to a static page; legacy migration where query strings were once tolerated; or routing utilities that preserve search params into the export target. Also appears after upgrading from an older Next.js version that silently ignored the query.

Related errors


AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06). Data as JSON: /api/errors/66e713be5332f4ac. Report an issue: GitHub.