{"record":{"id":"1ea10f966a197fbb","repo":"vercel/next.js","slug":"statically-exporting-a-next-js-application-via-ne","errorCode":null,"errorMessage":"Statically exporting a Next.js application via `next export` disables API routes and middleware.\nThis command is meant for static-only hosts, and is not necessary to make your application static.\nPages in your application without server-side data dependencies will be automatically statically exported by `next build`, including pages powered by `getStaticProps`.\nLearn more: https://nextjs.org/docs/messages/api-routes-static-export","messagePattern":"Statically exporting a Next\\.js application via `next export` disables API routes and middleware\\.\nThis command is meant for static-only hosts, and is not necessary to make your application static\\.\nPages in your application without server-side data dependencies will be automatically statically exported by `next build`, including pages powered by `getStaticProps`\\.\nLearn more: https://nextjs\\.org/docs/messages/api-routes-static-export","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/export/index.ts","lineNumber":649,"sourceCode":"  if (!options.buildExport) {\n    try {\n      const middlewareManifest = require(\n        join(distDir, SERVER_DIRECTORY, MIDDLEWARE_MANIFEST)\n      ) as MiddlewareManifest\n\n      const functionsConfigManifest = require(\n        join(distDir, SERVER_DIRECTORY, FUNCTIONS_CONFIG_MANIFEST)\n      )\n\n      hasMiddleware =\n        Object.keys(middlewareManifest.middleware).length > 0 ||\n        Boolean(functionsConfigManifest.functions?.['/_middleware'])\n    } catch {}\n\n    // Warn if the user defines a path for an API page\n    if (hasApiRoutes || hasMiddleware) {\n      if (nextConfig.output === 'export') {\n        Log.warn(\n          yellow(\n            `Statically exporting a Next.js application via \\`next export\\` disables API routes and middleware.`\n          ) +\n            `\\n` +\n            yellow(\n              `This command is meant for static-only hosts, and is` +\n                ' ' +\n                bold(`not necessary to make your application static.`)\n            ) +\n            `\\n` +\n            yellow(\n              `Pages in your application without server-side data dependencies will be automatically statically exported by \\`next build\\`, including pages powered by \\`getStaticProps\\`.`\n            ) +\n            `\\n` +\n            yellow(\n              `Learn more: https://nextjs.org/docs/messages/api-routes-static-export`\n            )\n        )","sourceCodeStart":631,"sourceCodeEnd":667,"githubUrl":"https://github.com/vercel/next.js/blob/258b1c1bc05f7099816b88f70b7b3422b24a4b8d/packages/next/src/export/index.ts#L631-L667","documentation":"Error \"Statically exporting a Next.js application via `next export` disables API routes and middleware.\nThis command is meant for static-only hosts, and is not necessary to make your application static.\nPages in your application without server-side data dependencies will be automatically statically exported by `next build`, including pages powered by `getStaticProps`.\nLearn more: https://nextjs.org/docs/messages/api-routes-static-export\" thrown in vercel/next.js.","triggerScenarios":"Thrown at packages/next/src/export/index.ts:638 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use `next build` with static optimization instead of `next export`; API routes and middleware are not available in static exports."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"258b1c1bc05f7099816b88f70b7b3422b24a4b8d","analyzedAt":"2026-08-19T02:10:13.922Z","contentChangedAt":"2026-08-19T02:10:13.922Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}