Static Exports
Export your pages statically, and deploy with Nginx , GitHub Pages and more.
Getting started
Configuration
To enable a static export, update the options in next.config.mjs file as
follows:
next.config.mjs
import nextra from 'nextra';
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
output: 'export',
images: {
unoptimized: true, // mandatory, otherwise won't export
},
// Optional: Change the output directory `out` -> `dist`
// distDir: "build"
};
const withNextra = nextra({
// ... other Nextra config options
});
export default withNextra(nextConfig);Update postbuild script
Update the Pagefind search engine setup to set the correct output path:
package.json
"scripts": {
"postbuild": "pagefind --site .next/server/app --output-path out/_pagefind"
}Building
Run the build command according to your package manager:
npm run buildBy default, static export will be stored in out directory in the root of your
project.
For more in detail documentation for static export visit Next.js docs .
Last updated on