Only output: 'export' belongs here
Next.js can run as a Node server (next start), as serverless targets, or as a fully static export. StaticHost hosts only the static export. If your app needs server components that hit databases per request, middleware that must run on a Node runtime, or route handlers, this is the wrong host. If you can produce an out/ directory of HTML and assets, continue.
There is no next start on StaticHost. There is no remote next build either—you build locally or in your CI. nginx serves files with try_files $uri $uri/ =404.
Enable static export
In next.config.js / next.config.mjs:
/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'export',
images: {
unoptimized: true,
},
// trailingSlash: true, // optional; match how you link paths
}
export default nextConfig
images.unoptimized: true is required for static export because the default Next Image Optimization API needs a server. Without it, builds fail or images expect a nonexistent optimizer.
Features incompatible with export (non-exhaustive): dynamic server routes that cannot be enumerated, server actions that require a server, ISR as a live process, and some middleware patterns. Next’s docs list restrictions; if next build errors on export, fix the app shape before blaming hosting.
Build and pack
npm ci
npm run build
ls out
Static export writes to out/ by default (not .next/ alone). Publish out/ contents:
cd out && zip -r ../next-static.zip .
unzip -l ../next-static.zip | head
Confirm top-level index.html. Upload to StaticHost or push to a GitHub artifact branch. The host will not run npm. Nested zip guide: zip without 404.
Routing reality
Export generates HTML for pages that exist at build time. App Router routes under app/ become files/directories in out/. Client-only navigations to exported routes work. Paths you never exported still 404—same as any strict static host. You do not get a soft SPA fallback for missing paths.
If you relied on client-side routing without generating files, either export those routes or use a different architecture. Related: SPA hosting.
Environment variables
NEXT_PUBLIC_* variables are inlined at build time. Build once per environment:
NEXT_PUBLIC_API_URL=https://api.staging.example.com npm run build
Use a separate StaticHost site for staging when keys differ—Pro ($30/mo, 3 sites, 10 GB, staging) fits that pattern.
Verification
- Deploy
out/to StaticHost; open HTTPS preview. - Hit
/, an interior page, and a dynamic segment you exported (/blog/my-post). - Confirm images load without calling
/_next/image. - Roll back via deploy history on failure.
- Attach custom domain after DNS verifies; certificate issues afterward.
When static export is the wrong choice
- Authenticated dashboards needing private server data on each request without a separate API.
- Preview mode that depends on Next’s server.
- Heavy use of Image Optimization, redirects in
next.configthat expect the Next server, or draft CMS previews tied tonext start.
For those, host the Next server elsewhere and keep StaticHost for marketing exports only—or do not use StaticHost for that app. PHP/WordPress is also a different host category.
Plans
Starter $9 (1 site, 2 GB), Pro $30 (3 sites, 10 GB, staging), Scale $65 (10 sites, 30 GB), Business $130 (30 sites, 100 GB, teams). Trial ~1 day; no forever-free; no cPanel; no email; no built-in CDN.
A realistic week shipping host a nextjs static export
Monday starts with a broken relative CSS path that only appears once the files leave a designer’s laptop. You flatten the zip so index.html sits at the archive root, redeploy to StaticHost, and HTTPS preview finally matches local intent. WordPress/PHP needs a different kind of host.
Wednesday adds a custom domain. DNS is created exactly as the dashboard specifies; verification lags an hour; the certificate appears afterward. Someone asks whether email is included—you point them at a mail vendor and keep MX untouched. Plans: Starter $9 (1 site, 2 GB), Pro $30 (3 sites, 10 GB, staging), Scale $65 (10 sites, 30 GB), Business $130 (30 sites, 100 GB, teams).
Thursday an engineer enables history-mode routing for a “cleaner URL.” Refresh on a nested path 404s. You revert to hash routing for the week’s deadline and schedule prerender work properly instead of inventing an nginx rewrite StaticHost will not apply. nginx behaves like try_files $uri $uri/ =404 with no SPA index fallback.
Friday staging on Pro receives a build with staging API URLs baked via public env prefixes. Production stays on last week’s known-good deploy until Monday’s review. Rollback remains one click if marketing’s late copy drop breaks mobile layout. Preview HTTPS is available immediately; custom-domain certificates issue only after DNS verifies.
StaticHost serves prebuilt files via zip or GitHub and does not run npm, Hugo, or Jekyll remotely.
That week is what host a nextjs static export looks like when the host stays boring and the team respects file truth.
Worked example: blog routes that must exist on disk
# next.config.mjs already has output: 'export' and images.unoptimized: true
npm ci
NEXT_PUBLIC_SITE_URL=https://preview.example.invalid npm run build
find out -type f -name '*.html' | head
cd out && zip -r ../next-out.zip .
Deploy next-out.zip. On HTTPS preview open /, /blog/hello-world/, and a media path under /_next/static/ (or your emitted asset paths). Confirm images never call /_next/image. If a dynamic segment is missing from out/, it will 404—generate it at build time or drop the link.
For staging versus production APIs, rebuild with different NEXT_PUBLIC_* values and deploy to separate sites (Pro at $30/mo fits). Do not expect next start or Image Optimization on StaticHost.
Failure table (Next static export)
| Symptom | Likely cause | Fix |
|---|---|---|
Uploaded .next/ and site breaks | Wrong artifact | Upload out/ after export |
Build errors on next/image | Optimizer expects a server | images.unoptimized: true or plain <img> |
| Dynamic path 404 | Not enumerated at build | Provide generateStaticParams / paths; rebuild |
| API routes missing | Route handlers need Node | Move APIs elsewhere; keep pages static |
Nested out/index.html in zip | Zipped parent | cd out before zip |
| Middleware assumptions fail | Edge/Node middleware not on this host | Remove or relocate middleware |
SSR-only apps, draft preview tied to a Next server, and WordPress belong on other products. Trial ~1 day; plans $9/$30/$65/$130; no forever-free, email, cPanel, or built-in CDN. nginx: try_files $uri $uri/ =404.
FAQ
Is .next/ what I upload?
No. Upload out/ after output: 'export'. .next/ is build machinery.
Can I use next export CLI like older tutorials?
Modern Next consolidates on output: 'export' with next build. Follow the version you use; the artifact is still a static directory.
Do server components work?
Only if they can render fully at build time for exported pages. They do not run on StaticHost per request.
How do I handle 404 pages?
Export a app/not-found (or pages equivalent) so a 404 document exists in out/. That is still not an SPA rewrite for arbitrary paths.
Can StaticHost run the Image Optimization endpoint?
No. Keep images.unoptimized: true or use plain <img> / external image CDN URLs.