The Be Sure Blog

Code Snippets | Problem Solving | Tips & Tricks

The Be Sure Blog banner

Do a static export of a Next.js website

posted on 8.1.2023 by Below Surface in "Next.js"

To do a static export of your Next.js project, you just need to open the package.json file in your text editor and add a single line to it.

Within "scripts", simply add the line:

"export": "next build && next export"

After this, your package.json may look like this:

  "name": "frontend",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint",
    "export": "next build && next export"
  "dependencies": {
    "next": "12.3.1",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-markdown": "^8.0.3",
  "devDependencies": {
    "eslint": "8.25.0",
    "eslint-config-next": "12.3.1"

Now you can do the static export by running the terminal command:

$ npm run export

Once the export is done successfully, your files are located in the newly created "out" folder. You can upload all files within this folder to your web server via FTP and reach your website under

More information to be found in the Next.js documentation.


static export

More posts of this category

Change the port of a Next.js app

How to manually set the port from 3000 to any other number


Next.js 13 - how to set dynamic HTML head titles

How to take a slug string and turn it into a HTML title tag


Suppress Next.js img tag warnings

If you don't want to use their Image elements, this is how to disable the warnings


Add a robots.txt to your Next.js website

How to add your robots.txt file


Add Tailwind CSS to your Next.js app

A few commands and some possible error fixing and you are good to go!


Next.js 13 Tailwind CSS hot-reload issue fix

With the currently experimental app directory, hot-reload does not work properly


How to clear the cache of a Next.js application

How to create a fresh build without any cached data


How i finally fixed "sh: 1: next: not found"

My release pipeline failed constantly and it took me three hours to figure out the issue


How I fixed "Parsing error: DeprecationError"

'originalKeywordKind' has been deprecated since v5.0.0 (...)