Next.js โ Static Export
Requirements:
- Node.js 18+
Create a new app:
npx create-next-app@latest my-next-appcd my-next-appnpm install
Run locally:
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/
):
npm run build
Note: With output: 'export'
, next build
also exports static HTML to out/
.
Preview out/
locally:
npx serve out
Deploy the out/
directory to any static host.