Skip to content

Next.js โ€” Static Export

Requirements:

  • Node.js 18+

Create a new app:

Terminal window
npx create-next-app@latest my-next-app
cd my-next-app
npm install

Run locally:

Terminal window
npm run dev

Visit http://localhost:3000

Enable static export (Next 13+):

  • In next.config.js add:
/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'export',
};
export default nextConfig;

Build and export (output to out/):

Terminal window
npm run build

Note: With output: 'export', next build also exports static HTML to out/.

Preview out/ locally:

Terminal window
npx serve out

Deploy the out/ directory to any static host.