GUIDES · BUILD CONFIGURATION

Next.js output export fails: dynamic routes, cookies and API handlers

Using output: export on Vercel? Learn why request-time routes, cookies, server handlers and default image optimization fail in a static export.

What output export actually means

With output: export, Next.js builds HTML and assets that can be served without a Node server. That is useful for static marketing sites, but it is fundamentally different from a server-rendered Next.js deployment on Vercel.

If your app needs authentication cookies, personalized requests, request-time API handlers, rewrites or Incremental Static Regeneration, a pure static export cannot deliver those server behaviors.

Remove export mode for server features

For a normal Next.js application hosted on Vercel, the simplest fix is often to remove output: export from next.config and let Vercel deploy the Next.js server functions. Do not copy a static-site template configuration into an app with an API or session cookie dependency.

// next.config.ts
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
  // Do not set output: "export" when server routes are required.
};
export default nextConfig;

If you really need static output

Dynamic App Router segments need generateStaticParams for every path that is built. Routes must avoid reading live request headers or cookies at render time. Default next/image optimization also requires configuration appropriate for static export, such as a custom loader or unoptimized images.

An API route that reads the incoming Request cannot be a static request handler. Move dynamic behavior to a separate backend or choose a server-capable deployment.

How to reproduce the root cause

Run npm run build with output export enabled and read the first unsupported-feature error, not the final stack trace. Identify which route requires request-time behavior before changing the whole project.

Reference: Next.js Static Exports documentation and its Unsupported Features section. DeployDoctor inspects build configuration and source patterns to surface some static export conflicts.

Updated 2026-10-21