Next.js
Deploy a Next.js site to LeafCloud.
Requirements
Section titled “Requirements”Validated with Node v24.22.1, Next.js 16.4.2, React 19.3.0, React DOM 19.3.0, and npm. Static export requires output: "export" and images: { unoptimized: true } in next.config.ts.
-
Create a project with the official starter:
Terminal window npx create-next-app@latest app --ts --eslint --app --no-src-dir --use-npm --yes < /dev/nullTerminal window cd app -
Update
next.config.ts. The validated change adds these settings and removes the starter’s incompatiblecacheComponents: trueandpartialPrefetching: truesettings:const nextConfig: NextConfig = {output: "export",images: { unoptimized: true },cacheComponents: true,partialPrefetching: true,}; -
Build and preview the deployment:
Terminal window leaf deploy --dry-runExpected output from the validated run:
Framework: Next.jsPackage manager: npmBuild command: npm run buildOutput directory: outFiles: 40Total size: 842034 bytesDry run: nothing was uploaded.A real deploy prints
✓ Live at <url> (<files> files, <uploaded> uploaded)instead of the final dry-run line.
What LeafCloud detects
Section titled “What LeafCloud detects”Next.js; npm run build; out.
Common problems
Section titled “Common problems”Next.js must set output: 'export' to deploy as a static site— addoutput: "export"tonext.config.ts.Next.js server features cannot be deployed as a static site: revalidate— remove the server feature, such asexport const revalidate = 60;.Next.js server features cannot be deployed as a static site: next/image without images.unoptimized: true (<project>/app/page.tsx)— addimages: { unoptimized: true }tonext.config.ts.
For agents
Section titled “For agents”Run leaf deploy --dry-run --json first.
Check the exit code and stop if the JSON contains "error".
After a successful dry run, run leaf deploy --json --yes.
Never print credentials.
Validated on 2026-10-23 with Next.js 16.4.2.