Skip to main content

Deploy a Next.js App

Next.js is a React framework for building apps and websites. With Webpod, you can deploy your Next.js app in minutes, to your own server.

Next.js can be deployed as a static site, or as a server-rendered app.

  • Static Export: Next.js will generate a static version of your app.
  • Node Server: Next.js will run a Node.js server to render your app.

Static Export

To deploy a static Next.js app, you'll need to export your app to static HTML files. To enable a static export, update your output mode in next.config.js:

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

Then, build your app:

npm run build

Next.js will generate a out directory with your static HTML files.

Now you can deploy your app to Webpod:

npx webpod --uploadDir=out --publicDir=.

Node Server

Webpod automatically detects Next.js apps and runs them as Node.js servers.

Simply run the following command to deploy your app:

npx webpod

If you want to manually configure your deployment, you can specify the scripts option:

npx webpod --scripts='node_modules/.bin/next start'
tip

We can not use npm start here. We need to specify the full path to the next binary. This allows Webpod to run your app in a cluster mode. And utilize all CPU cores of your server.