Blog · Tutorial

How to deploy a Next.js app.

To deploy a Next.js app, build it with next build, run it with next start on a Node.js server, set your environment variables, and put HTTPS in front. This guide covers each step for any host, then shows the short version on Runex.

Published Sep 24, 2026Updated Sep 25, 20263 min read

key takeaways
  • next build then next start
  • SSR and API routes need a Node.js server
  • NEXT_PUBLIC_* is baked in at build time
  • output: "standalone" for small Docker images
tl;drrunex

Checklist

What are the steps to deploy Next.js?

Six steps, on any host.

  1. Confirm next build succeeds from a clean clone.
  2. Pick a Node.js version your Next.js release supports.
  3. Serve with next start: it reads PORT and binds 0.0.0.0.
  4. Set server secrets and NEXT_PUBLIC_* values before building.
  5. Put HTTPS and your domain in front of the server.
  6. Automate it: redeploy on every push to main.

Compare

next start vs standalone output: which should you use?

Use next start by default; use standalone for small Docker images. Runex supports both, and the Next.js hosting guide covers each setup.

next start vs standalone output: which should you use?
Defaultnext startoutput: "standalone"standalone
What runsThe full app with node_modulesA minimal server.js bundle
Image sizeLargerMuch smaller
SetupNoneConfig flag plus a Dockerfile
Best forMost deploymentsContainer-first teams

Configuration

How do environment variables work in Next.js?

Server variables are read at runtime; NEXT_PUBLIC_* variables are inlined at build time. On Runex you set them in the dashboard, as described in environment variables.

.env (never commit)
DATABASE_URL=postgres://…        # server only
STRIPE_SECRET_KEY=sk_live_…      # server only
NEXT_PUBLIC_API_URL=https://api.acme.com
# ↑ visible in the browser bundle
.env (never commit)runex

Changing a NEXT_PUBLIC_* value needs a rebuild, not just a restart.

On Runex

How do you deploy Next.js on Runex?

The same steps, handled for you. Every pull request also gets its own preview deployment.

  1. You

    Push to GitHub

    App Router or Pages Router.

  2. You

    Connect the repo

    Install the Runex GitHub App.

  3. You

    Add variables

    In the dashboard.

  4. Runex

    Build and serve

    next build, next start, HTTPS.

FAQ

Frequently asked questions

Short answers to related searches.

Can I deploy Next.js without Vercel?

Yes. Next.js runs on any Node.js server with next start, or in a container using standalone output. Platforms like Runex host it that way.

Does next export still work?

Static export now uses output: "export" in next.config.js. It produces static files with no server, so SSR and API routes aren't available.

Which Node.js version does Next.js need?

Check the Next.js release notes for your version. Recent releases require Node.js 18.18 or later; Node.js 20 or 22 is a safe choice.

Why is my Next.js app slow after deploying?

Common causes are running next dev instead of next start, missing caching headers, or a database far from the app server.

Next step

Put it into practice.

Deploy an app from GitHub on Runex and get a live HTTPS URL. Free to start.