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.
- 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
Checklist
What are the steps to deploy Next.js?
Six steps, on any host.
- Confirm next build succeeds from a clean clone.
- Pick a Node.js version your Next.js release supports.
- Serve with next start: it reads PORT and binds 0.0.0.0.
- Set server secrets and NEXT_PUBLIC_* values before building.
- Put HTTPS and your domain in front of the server.
- 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.
| Defaultnext start | output: "standalone"standalone | |
|---|---|---|
| What runs | The full app with node_modules | A minimal server.js bundle |
| Image size | Larger | Much smaller |
| Setup | None | Config flag plus a Dockerfile |
| Best for | Most deployments | Container-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.
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
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.
-
You
Push to GitHub
App Router or Pages Router.
-
You
Connect the repo
Install the Runex GitHub App.
-
You
Add variables
In the dashboard.
-
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.
