Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk4 min

How to Configure Next.js for Static Hosting with `output: ‘export’`

Set output: 'export' and run next build to generate static files in out. Check unsupported runtime features, image handling, and host route resolution before deploying.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To generate a static Next.js site, set output: 'export' in your Next.js configuration and run next build. Next.js writes the generated files to out by default; deploy those files to a static host. First check that your app does not depend on server-only features that a static export cannot provide.

1. Check whether static export fits your app

A static export works when the pages and assets your site needs can be produced during the build and served as files. It does not run a Next.js server after deployment to handle requests. The Next.js Static Exports guide lists these unsupported cases for the documented export path:

As an Amazon Associate I earn from qualifying purchases.

  • Internationalized routing
  • API Routes, rewrites, redirects, headers, and Proxy
  • Incremental Static Regeneration (ISR) and Draft Mode
  • getServerSideProps
  • getStaticPaths with fallback: true or fallback: 'blocking'
  • The default next/image optimization loader

For App Router Route Handlers, there is a narrower supported case: only GET handlers work in export mode when the route segment sets dynamic = 'force-static'. The build can emit static data files this way, but the result is not a general-purpose runtime API server. See the Next.js Backend for Frontend guide.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If the app needs request-time behavior or another excluded feature, use a deployment with a Next.js runtime instead. The deployment overview describes static export support as limited and Node.js server deployment as supporting all Next.js features.

#1 Best Overall
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

2. Enable export in the Next.js config

Add output: 'export' to the project configuration. Use the syntax matching your config file. The Pages Router example uses CommonJS in next.config.js; the App Router SPA guide also shows an ES module TypeScript config in next.config.ts.

CommonJS: next.config.js

/** @type {import('next').NextConfig} */
const nextConfig = {
  output: 'export',
}

module.exports = nextConfig

TypeScript: next.config.ts

import type { NextConfig } from 'next'

const nextConfig: NextConfig = {
  output: 'export',
}

export default nextConfig

These are alternative config styles; use the one appropriate to the config file your project already has. The setting and build behavior are documented in the Static Exports guide.

Rank #2
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

3. Choose URL and output-directory settings

Next.js emits route files whose paths need to agree with the URLs your host serves. Set these optional config values only when they match your routing and hosting setup:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Setting Effect
trailingSlash: true Changes a route such as /me to /me/ and emits /me/index.html instead of /me.html.
skipTrailingSlashRedirect: true Prevents Next.js from automatically redirecting /me to /me/ and preserves the requested href behavior.
distDir: 'dist' Changes the export directory name from the default out to dist.

For example, add a slash preference alongside the export setting:

const nextConfig = {
  output: 'export',
  trailingSlash: true,
}

Choose the URL shape your static host can resolve. The Next.js guide’s Nginx example uses try_files and a rewrite for the trailingSlash: false case; it notes that the special blog rewrite can be omitted with trailingSlash: true. See the Static Exports guide for the server configuration example.

4. Build the static files

Run the production build from the project directory:

next build

With export enabled, Next.js generates route HTML and static assets in out, unless you changed the directory with distDir. The documentation’s example output includes index.html, 404.html, and HTML for concrete dynamic-route values such as /blog/post-1.html. Check the generated directory after building and confirm that the routes you expect to publish have corresponding files.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

5. Make image delivery work without the default optimizer

The default next/image optimization loader is unsupported with static export. If you keep using next/image, configure a custom loader with images.loader: 'custom' and images.loaderFile; the official example constructs image URLs for Cloudinary. Alternatively, optimize images separately and serve the resulting files.

Best Value
Sale
JavaScript and jQuery: Interactive Front-End Web Development
  • JavaScript Jquery
  • Introduces core programming concepts in JavaScript and jQuery
  • Uses clear descriptions, inspiring examples, and easy-to-follow diagrams

A custom or remote image service may optimize images at runtime rather than during the static build. That means page export alone does not make the image service’s work build-time. The options and example are in the Static Exports guide and self-hosting guidance.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

6. Deploy the export directory and check route resolution

Publish the contents of the export directory—not a running Next.js server—to a static file host. The generated HTML, CSS, JavaScript, and other assets can be served by a web server capable of delivering static files; the official guide names AWS S3, Nginx, and Apache as examples.

  1. Build the app with next build.
  2. Upload the contents of out, or your configured export directory, to the static host.
  3. Configure the host to resolve URLs to the emitted files using the same slash and filename behavior you selected in Next.js.
  4. Verify a nested route, its assets, and a missing route such as a deliberate 404. If clean URLs do not map correctly, adjust the host’s file resolution or your slash setting.

The key requirement is file serving, not a particular provider: “Since Next.js supports this static export, it can be deployed and hosted on any web server that can serve HTML/CSS/JS static assets.” — Next.js documentation, “Guides: Static Exports”, last updated March 25, 2026.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Static export is not necessarily a single-page app

A Next.js static export can generate HTML for each route rather than one client-rendered shell. That can provide route-specific HTML and automatic code splitting; separate route files can also avoid loading unnecessary JavaScript. Client-side navigation can still provide SPA-like transitions. The distinction matters when choosing a host and rendering strategy: export describes how the app is built and deployed, not a requirement that every route share one HTML entry point. See the Static Exports guide and SPA guide.

Quick Recap

SaleBestseller No. 1
HTML and CSS: Design and Build Websites
HTML and CSS: Design and Build Websites
HTML CSS Design and Build Web Sites; Comes with secure packaging; It can be a gift option
$14.94
SaleBestseller No. 2
Web Design with HTML, CSS, JavaScript and jQuery Set
Web Design with HTML, CSS, JavaScript and jQuery Set
Brand: Wiley; Set of 2 Volumes
$35.05
SaleBestseller No. 3
SaleBestseller No. 5
JavaScript and jQuery: Interactive Front-End Web Development
JavaScript and jQuery: Interactive Front-End Web Development
JavaScript Jquery; Introduces core programming concepts in JavaScript and jQuery; Uses clear descriptions, inspiring examples, and easy-to-follow diagrams
$22.28

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.