Next.js supports two kinds of production usage, static and dynamic, the main difference being that a static build can be served by any static HTTP server as a static website, whereas dynamic usage means that there will be a Next.js server that executes the production build:
- Static mode is best suited for simple websites with no dynamic content. We need to add a script to package.json:
{
"scripts": {
"build": "next build",
"static": "next export"
}
}
- Then, we have to add a next.config.js with a path map (this was fixed in 6.0.0; you no longer have to do it for 1-1 matches of filesystems and URLs):
// next.config.js
module.exports = {
exportPathMap: () => ({
'/': {page: '/'}
})
};
- Now...