How to deploy Next.js to your own VPS.
To run Next.js on a VPS you need Node.js, a service that keeps the app running, Nginx in front for HTTPS, and a way to switch versions without dropping requests. ServerDog sets that up from your Mac: it installs Node.js 24, runs the app as a systemd service behind Nginx, and deploys each commit as a new release that takes over only once it answers.
By ServerDog. Updated .
Key facts
- ServerDog installs Node.js 24 LTS on the server and runs each Node site as a systemd service that restarts whenever it stops.
- Nginx sits in front as a reverse proxy and handles HTTPS with a Let’s Encrypt certificate.
- Node deploys are always zero-downtime: the new release starts on a second port, and Nginx switches to it only after it answers.
- The default commands for Next.js are npm ci, npm run build and npm run start. You can change them, and pick pnpm or Yarn instead.
- There is no Docker and no per-site Node version.
Before you start
- A Mac running macOS 15 or later, with ServerDog installed.
- A Hetzner or DigitalOcean account, or a fresh Ubuntu 24.04 or 26.04 server from any provider.
- Your Next.js app in a GitHub, GitLab or Bitbucket repository.
- A domain whose DNS you can change.
1. Set up the server
Choose Add Server and pick App server or Web server. Both install Node.js 24 LTS by default, along with Nginx and the firewall. A Web server skips the database and cache, which suits an app that keeps its data elsewhere.
2. Create the site
Choose New Site and the Next.js preset. Type the domain, pick npm, pnpm or Yarn, and add the repository URL and branch. The site gets its own read-only deploy key, created on the server.
The preset fills in defaults you can edit:
- Install:
npm ci - Build:
npm run build - Start:
npm run start -- -H 127.0.0.1
3. Set the environment
Add your variables in the site’s Environment tab. The file is shared across releases, readable only by the site’s user, and loaded each time the app starts. ServerDog sets PORT, HOST andNODE_ENV=production for you.
4. Deploy
Press Deploy. For a Node site, every deploy is zero-downtime:
- ServerDog checks out the commit into a new release folder, installs dependencies and builds.
- It starts the new release on the site’s second port. Each site has two local ports for this.
- It waits up to a minute for the new release to answer.
- It points Nginx at the new release and reloads Nginx.
- Ten seconds later it stops the old instance.
If the new release never answers, the site keeps serving the previous one.Read how zero-downtime deploys work.
5. Point the domain and turn on HTTPS
Create a DNS record for your domain that points at the server’s IP address. ServerDog waits for DNS, requests a free Let’s Encrypt certificate and shows how long it is valid. The server renews it from then on.
6. Turn on Deploy on Push
In the site’s deploy settings, turn on Deploy on Push. The server checks the repository itself and deploys your branch within a minute of each new commit. There is no webhook to set up, and your Mac doesn’t need to be on.
Can I deploy a static export instead?
Yes. Choose the Static runtime when you create the site. ServerDog runs your build and serves theout folder with Nginx, with no Node process to keep running. Set output: 'export' in your Next.js config yourself; ServerDog does not change it.
Which other Node frameworks have presets?
Each preset fills in a default start command and, where the framework can export a static site, the folder to serve.
| Framework | Default start command | Static folder |
|---|---|---|
| Next.js | npm run start -- -H 127.0.0.1 | out |
| Nuxt | node .output/server/index.mjs | .output/public |
| Astro | node ./dist/server/entry.mjs | dist |
| SvelteKit | node build | build |
| React Router | npx react-router-serve ./build/server/index.js | build/client |
| NestJS | node dist/main | None (server only) |
What you end up with
A plain Ubuntu server running Nginx and Node.js 24, with your app as a systemd service behind it and served over HTTPS. There are no containers and nothing tied to a hosted service: remove the server from ServerDog and it keeps running exactly as it is.
Go deeper
Questions
Can I host Next.js on my own VPS?
Yes. A Next.js app runs anywhere Node.js does. On a VPS you need Node.js, a process manager to keep the app running, and a web server such as Nginx in front for HTTPS. ServerDog sets up all three and deploys from your Git repository.
How does ServerDog keep a Next.js app running?
As a systemd service that runs as the site’s user and restarts whenever it stops. Nginx passes requests to it on a local port, with the headers WebSockets need.
Are Next.js deploys zero-downtime?
Yes, always. Each deploy builds a new release, starts it on a second port and waits up to a minute for it to answer. Then Nginx switches to it and the old instance stops ten seconds later. If the new release never answers, the site keeps serving the previous one.
Which Node.js version does ServerDog install?
Node.js 24 LTS, one version per server. There is no per-site Node version.
Can I use pnpm or Yarn?
Yes. Choose npm, pnpm or Yarn when you create the site. ServerDog does not detect it from your lockfile.
Does ServerDog support a static export?
Yes. Choose the Static runtime and ServerDog serves the export folder with Nginx, with no Node process. You still set output: "export" in your own Next.js config.
Does this work for Nuxt, Astro, SvelteKit and NestJS?
Yes. ServerDog has presets for Next.js, Nuxt, Astro, SvelteKit, React Router and NestJS, each with its own default start command, and any other Node app can use its own.
Last updated by ServerDog.