{"record":{"id":"aa121c37ecbaa532","repo":"vercel/next.js","slug":"the-provided-export-path-pathname-doesn-t-mat","errorCode":null,"errorMessage":"The provided export path '${pathname}' doesn't match the '${page}' page.\nRead more: https://nextjs.org/docs/messages/export-path-mismatch","messagePattern":"The provided export path '(.+?)' doesn't match the '(.+?)' page\\.\nRead more: https://nextjs\\.org/docs/messages/export-path-mismatch","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/export/helpers/get-params.ts","lineNumber":32,"sourceCode":" * Gets the params for the provided page.\n * @param page the page that contains dynamic path parameters\n * @param pathname the pathname to match\n * @returns the matches that were found, throws otherwise\n */\nexport function getParams(page: string, pathname: string) {\n  // Because this is often called on the output of `getStaticPaths` or similar\n  // where the `page` here doesn't change, this will \"remember\" the last page\n  // it created the RegExp for. If it matches, it'll just re-use it.\n  let matcher: RouteMatchFn\n  if (last?.page === page) {\n    matcher = last.matcher\n  } else {\n    matcher = getRouteMatcher(getRouteRegex(page))\n  }\n\n  const params = matcher(pathname)\n  if (!params) {\n    throw new Error(\n      `The provided export path '${pathname}' doesn't match the '${page}' page.\\nRead more: https://nextjs.org/docs/messages/export-path-mismatch`\n    )\n  }\n\n  return params\n}\n","sourceCodeStart":14,"sourceCodeEnd":39,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/export/helpers/get-params.ts#L14-L39","documentation":"Thrown by getParams() in the static-export pipeline when a candidate export pathname fails to match the page's compiled route regex. Next.js derives a regex from the page's dynamic route pattern (e.g. /blog/[slug]) and runs the supplied pathname through getRouteMatcher; a falsy result means the path cannot satisfy the route's parameter shape, so export is aborted. It guards against writing prerendered files to paths that the route could never actually serve.","triggerScenarios":"Occurs during `next build`/`next export` (or the export worker) for a dynamic route when getStaticPaths returns a path whose segments do not align with the route file, or an exportPathMap entry references a pathname that does not match the page's bracket-pattern. Also fires if a custom export path is hand-fed to getParams with the wrong segment count, optional catch-all mismatch, or trailing-slash difference.","commonSituations":"Typical during static export of a Pages Router dynamic route after editing getStaticPaths (returning paths like '/post' for a '/post/[slug]' page), or after renaming a route file without updating getStaticPaths. Also seen when exportPathMap is composed manually for a route whose pattern changed in a Next.js version upgrade, or when catch-all segments ([...slug]) are partially filled.","solutions":["Inspect the route file pattern and confirm every path returned by getStaticPaths (or set in exportPathMap) has the exact segment count and param positions the pattern requires.","Re-check trailing slash and base path settings (trailingSlash, basePath in next.config.js) since these change the pathname that getParams receives.","For optional catch-all routes, ensure paths omit (or fully provide) the optional segments consistently rather than mixing partial values.","Add a unit test that runs getStaticPaths output through the route matcher before deploying, to catch mismatches at CI time."],"exampleFix":"// before: route file pages/post/[slug].js\nexport async function getStaticPaths() {\n  return { paths: [{ params: { slug: 'a' } }, { params: {} }], fallback: false } // {} mismatches [slug]\n}\n// after\nexport async function getStaticPaths() {\n  return { paths: [{ params: { slug: 'a' } }, { params: { slug: 'b' } }], fallback: false }\n}","handlingStrategy":"validation","validationCode":"import { getRouteMatcher } from 'next/dist/shared/lib/router/utils/route-matcher'\nimport { getRouteRegex } from 'next/dist/shared/lib/router/utils/route-regex'\n\nfunction validateExportPaths(page: string, paths: string[]): string[] {\n  const matcher = getRouteMatcher(getRouteRegex(page))\n  const bad = paths.filter((p) => !matcher(p))\n  if (bad.length) throw new Error(`Paths not matching ${page}: ${bad.join(', ')}`)\n  return paths\n}\n// call inside getStaticPaths or a pre-export check","typeGuard":"function isValidExportPath(page: string, pathname: string): boolean {\n  try {\n    const { getRouteMatcher } = require('next/dist/shared/lib/router/utils/route-matcher')\n    const { getRouteRegex } = require('next/dist/shared/lib/router/utils/route-regex')\n    return Boolean(getRouteMatcher(getRouteRegex(page))(pathname))\n  } catch {\n    return false\n  }\n}","tryCatchPattern":"try {\n  await nextBuild()\n} catch (e) {\n  if (e.message.includes(\"doesn't match the '\")) {\n    console.error('Export path mismatch — verify getStaticPaths vs route file')\n  }\n  throw e\n}","preventionTips":["Keep getStaticPaths paths and the route filename in the same change/commit so they stay in sync.","Add a unit test that runs getStaticPaths output through the route matcher before deploying.","Avoid hand-editing exportPathMap for dynamic routes; derive paths from data.","Run `next build` locally before pushing — this error always surfaces at build time."],"tags":["static-export","routing","dynamic-routes","build"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}