Next.js deployment guide

Deploy a Next.js app to a VPS without losing a weekend

Your app works locally, but production needs more than `next build`. You need a Node process, reverse proxy, SSL, env vars, logs, and a repeatable deploy path.

What is probably broken

The build passes locally, but the server has missing env vars, a dead Node process, or Nginx pointing at the wrong port.

What production should look like

A live Next.js app on your domain, served behind Nginx with HTTPS and a deployment path you can repeat.

STEP 01

Prepare the production build

Start by making the app build cleanly with production env vars present. Most broken deploys are not server problems, they are hidden build assumptions.

  • Run `npm run build` locally with production-like variables.
  • Confirm the app uses the correct Next.js output mode for your host.
  • Keep secrets out of git and load them from the server environment.

STEP 02

Run Next.js as a long-lived process

A VPS does not keep your app alive automatically. Use a process manager so deploys and restarts are predictable.

  • Install dependencies on the server with the same package manager used locally.
  • Run the app behind PM2 or another process supervisor.
  • Capture logs before adding Nginx so app errors are visible.

STEP 03

Put Nginx and SSL in front

Nginx handles public traffic, TLS, compression, and proxying to the private Node port.

  • Point DNS to the VPS before requesting SSL.
  • Proxy requests from port 80/443 to the Next.js process port.
  • Use Certbot or your preferred ACME client for HTTPS renewal.

Quick check

Is your app production-ready?

If you cannot tick all five, we can fix it. Send us the repo and we handle the rest.

  • ?Custom domain with HTTPS
  • ?Environment variables configured
  • ?Database wired and backed up
  • ?Auto-deploy on push
  • ?Smoke tested and live

Free checklist

Deploying this yourself?

Get the exact 5-step checklist we run before every deploy. No fluff, just the things that actually break.

No spam. Your email is only used to send the checklist.

Done-for-you deploy

Want this handled for you? RepoAssistant deploys Next.js apps to VPS with HTTPS, env vars, and handover notes.

Fixed price per repo. 24h delivery or full refund. No hourly billing.

Deploy my app

Related guides