Static Export in Next.js: When & How
N نکست.جی‌اس

Static Export in Next.js: When & How

output: 'export' for fully static sites — limitations with SSR and dynamic features.

BugCast Admin··۵ دقیقه مطالعه

Static export generates pure HTML/CSS/JS without a Node server. Great for marketing sites; incompatible with many App Router server features.

Common Interview Questions

Q: How to enable static export?

Answer: Run next build — outputs out/ directory deployable to any static host (S3, GitHub Pages, Netlify).


// next.config.js
module.exports = { output: "export" };

Q: What breaks with static export?

Answer: Server Actions, dynamic SSR without generateStaticParams, Image Optimization API (use unoptimized or external loader), rewrites, headers, middleware.

Q: Dynamic routes with export?

Answer: Must use generateStaticParams for all dynamic segments or pages won't exist in output.

Q: When choose static export?

Answer: Marketing/docs sites with no server logic, maximum CDN portability, or embedding in non-Node environments.

Key Points for Interviews

  • No server required after build

  • Trade dynamic features for simplicity

  • images.unoptimized often required

  • Good fit for Jamstack marketing sites

  • Contrast with Vercel default hybrid model

#static#export#interview

مطالب مرتبط