Shipping a Next.js Static Export to an Ordinary Web Server

The homepage loads from the exported directory. I follow a link to an exhibit, see its title and picture, and could reasonably believe the site is ready to hand over. Refreshing that same exhibit URL is a rather better test.
A Next development server knows what the route means. An ordinary web server may only know that nobody has uploaded a file with that name. Client navigation can conceal the difference until someone follows a bookmark.
My example is a small museum guide, with English and French exhibit pages. I want to serve it from static files, both at the domain root and beneath /guide. There will be no Next request server waiting behind the directory to rescue a missed assumption.
Exporting Means Giving up the Request Server
Generating a page during next build does not by itself make the entire application a static export. A normal Next deployment can combine generated pages with request‑time work.
For this Next 12 example, I run next build followed by next export, then serve the resulting out directory with an ordinary file server. The application does not use next start during the hosting checks.
That separation matters. My comparison of static generation and server‑side rendering covers when a page gets its data. Here the additional question is what remains available after the build machinery has stopped.
The answer should be a collection of HTML, JavaScript, styles, images, and data files. A request handler which exists only in the source tree has not somehow been squeezed into the upload.
I use a tiny static server for the lab because its rules are visible. It reads files and applies the declared URL policy. It does not import Next, render React, call an API, or generate a missing exhibit.
Name Every Page Which Must Exist
The museum has two known exhibits in each of two languages. I enumerate those combinations with getStaticPaths:
export async function getStaticPaths() {
return {
paths: locales.flatMap((locale) =>
exhibits.map((exhibit) => ({
params: { locale, slug: exhibit.slug },
})),
),
fallback: false,
};
}These are explicit /[locale]/exhibits/[slug] paths. They are not Next's built‑in internationalised routing configuration, which static export does not support. The language segment is part of the route I generate.
The matching getStaticProps looks up the record and supplies the title, language, and image prefix. A missing required content source throws during the build. I would rather have a failed release than a successfully uploaded museum with no exhibits.
My getStaticPaths article explains the route enumeration itself. The constraint here is that there is no runtime fallback capable of creating another page after upload. Adding an exhibit requires a new export.
I include an accented slug, café-radio, as well as the simpler desk-lamp. The browser sends an encoded path, the host decodes it for its file lookup, and both must identify the same exhibit. Testing only letters, digits, and hyphens would leave that agreement unexamined.
Language selection also needs honest scope. These pages do not negotiate a language from a request header or redirect visitors according to a cookie. A host could add those policies, but they would be host features requiring their own checks.
Agree on What an Extensionless URL Means
I build the guide in two file shapes. With trailingSlash: true, a deep page can be represented by an index.html inside its own directory. Without it, the corresponding output uses an HTML file alongside other files.
The URL still needs mapping to that output. One host policy serves directory indexes and redirects a directory request to its trailing‑slash form. The other resolves an extensionless request to the matching .html file.
Neither policy is magically inherited from the Next configuration. The uploaded files and the host's lookup rules have to agree.
My negative control serves the extension‑style export through the directory‑only policy. The deep request fails even though the exhibit's HTML exists. That is a hosting mismatch, and changing the React component would be an admirably indirect way of fixing it.
I test direct entry and refresh for every generated page under both correct policies. I also inspect the redirect status and destination when someone uses the other slash form. The host's behaviour should be a written choice, not an accidental sequence of redirects supplied by several different layers.
Build the Prefix into the Right Places
For the subdirectory variant, the application configuration includes:
module.exports = {
basePath: '/guide',
trailingSlash: true,
};I rebuild with that setting. Moving the root export into a directory called guide does not rewrite the URLs already embedded in its HTML and JavaScript.
Next's links account for the configured base path. My ordinary image does not acquire it automatically, so its source is built as /guide/images/lamp.svg for that variant. The root build uses /images/lamp.svg.
The image is a small original SVG with explicit dimensions. That keeps this example self‑contained and avoids assuming the host has Next's image‑optimisation endpoint. Other image strategies are possible, including a suitable custom loader, but the default server‑dependent loader is not supplied by a folder of files.
The prefix control deliberately mounts a root build at /guide. Its HTML can be served, but its unprefixed image request points outside that mount and fails. This is why a successful document response is only part of the check.
For the correct builds, I follow a real Next link as well as loading pages directly. I record the requested scripts, styles, generated data, and images, then check their responses. A page with a convincing heading and a failed script request is not a successful export.
Keep Missing Pages Missing
An unknown exhibit must return a real HTTP 404 and the exported missing‑page content. Serving index.html with a 200 for every unknown path may make a single‑page application seem more forgiving, but it would conceal missing routes in this guide.
The host reads the exported error document, 404.html or 404/index.html depending on the output layout, whilst preserving the 404 status. The browser‑visible message and the response status are checked separately.
The same restriction applies to an imagined /api/exhibits endpoint. This server returns 404 there. If the client needs a runtime API, that API must exist somewhere else and become an explicit dependency; an API‑route source file is not a static service.
I also keep a page using getServerSideProps as an export failure control. The normal Next build can accommodate it, but the export cannot turn a request‑time function into an ordinary file.
Regeneration deserves a separate check. In this Next 12 fixture, a page with revalidate can export successfully, yet the static host has nothing which can regenerate it. The lab gives that page a timestamp and a one‑second interval. Reading the file after the interval still returns the exported timestamp. Successful export is not proof that the original freshness promise survived.
Hand Over the Host Contract Too
The deliverable includes the route inventory, the chosen slash policy, the mount prefix, and the expected treatment of unknown URLs. I would want the person uploading the directory to know those details without reading through the application's components.
The checks use a deliberately small file server, so they do not certify an Apache, Nginx, or CDN configuration I haven't run. They do provide a sequence to repeat on the intended host: direct load, reload, client navigation, assets, redirects, and genuine missing‑page status.
Once that sequence passes with the Next server absent, the export is doing the job I asked of it. The homepage can have its moment then.
Postscript
November 2026: This walkthrough uses the Next 12 export workflow. Next 13.3 introduced output: 'export', and Next 14 removed next export. My static‑export lab keeps the Next 12.0.4 comparison alongside a Next 16.4.6 companion using the newer configuration. The current build rejects the ISR control rather than exporting an inert revalidation promise. Both comparisons still serve ordinary files and build the root and /guide variants separately; changing the command doesn't make the host's path rules disappear.