Guide
Deploy a Next.js app from GitHub to a London server
Published · 8 min read
Short answer
Next.js does not need a special platform. Its documentation says it can run on any provider that supports Node.js or Docker, and both options support every Next.js feature. To deploy from GitHub to a London server you need a repository with build and start scripts, Node.js 20.9 or later, your environment variables set before the build (anything starting with NEXT_PUBLIC_ is fixed into the browser code at build time), and a reverse proxy in front of the Next.js server, which the Next.js team recommends when self-hosting. You can wire that up yourself on a Linux server, or use a platform that builds every push for you.
Three ways Next.js can run
The Next.js deployment documentation lists a Node.js server, a Docker container and a static export, plus adapters for specific platforms. For a London server, the first two are the ones that matter:
| Option | Feature support | What it means for you |
|---|---|---|
Node.js server (next build, then next start) | All features | Any server with Node.js can run it. The simplest route. |
| Docker container | All features | The same, packaged as an image. Easier to roll back and to run several apps on one server. |
Static export (output: 'export') | Limited | Plain HTML, CSS and JavaScript. No features that need a server, such as cookies, Server Actions, Proxy, Incremental Static Regeneration or Image Optimization with the default loader. |
If your app reads cookies, uses Server Actions or Proxy, or relies on next/image with the default loader, you need one of the first two.
Get the repository ready
- 01
Check the scripts
Your
package.jsonneeds abuildscript (next build) and astartscript (next start). Projects made withcreate-next-apphave both. - 02
Pin the Node.js version
Next.js 16 needs Node.js 20.9 or later. Set
engines.nodeinpackage.json(or add an.nvmrc) so a build server that reads it uses the same major version as your laptop. - 03
Commit the lock file
Commit
package-lock.json,pnpm-lock.yaml,yarn.lockorbun.lock, so the server installs exactly the versions you tested. - 04
Keep secrets out of Git
The default
create-next-apptemplate adds.envfiles to.gitignore, and the Next.js documentation says you almost never want to commit them. Set the values on the server or platform instead. - 05
Build once locally
Run the production build on your own machine. If
next buildfails there, it will fail on the server too, and the error is easier to read locally.
Environment variables: build time or run time
This is the part that catches most people out when they leave a platform that hides it.
- By default a variable is only available on the server. Your database URL or API key stays out of the browser unless you expose it.
- `NEXT_PUBLIC_` variables are inlined at build time. Next.js replaces them with their value in the JavaScript sent to the browser during
next build. After the build, changing the variable does nothing: you have to build again. Treat anything with this prefix as public. - Server-side values can change at run time. The Next.js self-hosting guide shows reading
process.envduring dynamic rendering, so one build can run with different values. That is how one image can move from preview to production.
Optional: standalone output for smaller images
Setting output: 'standalone' in next.config.js makes next build create a .next/standalone folder with only the files needed in production, including the parts of node_modules your app uses, and a small server.js you can run instead of next start. Docker images built this way are much smaller.
- The standalone server does not copy
publicor.next/staticby default. Copy them into.next/standalone/publicand.next/standalone/.next/static, andserver.jsserves them. - Set
PORTandHOSTNAMEto choose where it listens, for examplePORT=8080 HOSTNAME=0.0.0.0 node server.js. - You do not need standalone output to deploy.
next startsupports every feature too; standalone is about image size.
What the server around Next.js has to do
Next.js is only the app. Someone still has to look after what sits around it:
| Job | Why it matters |
|---|---|
| A reverse proxy in front | The Next.js self-hosting guide recommends one (it names nginx) rather than exposing the Next.js server directly, to deal with malformed requests, slow connection attacks, payload size limits and rate limiting. |
| HTTPS certificates | Issued for each hostname and renewed before they expire. |
| No response buffering | Streaming and Suspense need the proxy to pass responses through without buffering them; the guide shows the X-Accel-Buffering: no header for nginx. |
| Persistent disk for the cache | By default Next.js caches pages and data on the local disk of each server, which works automatically for one next start instance with a persistent disk. Several instances need a shared cache handler. |
| Restarts and graceful shutdown | On SIGTERM or SIGINT, Next.js finishes in-flight requests and pending after() work; the documentation suggests allowing 10 to 30 seconds. |
| Operating system updates | The server underneath needs security updates like any other. |
Doing all of this by hand on a Linux server is a reasonable weekend project. Doing it again for every push and every pull request is where a deployment platform earns its keep.
Connecting GitHub safely
Most deployment platforms connect through a GitHub App. When you install one, GitHub shows the permissions it asks for, and if it needs repository access you choose All repositories or Only select repositories. Choose only the repositories you want to deploy. GitHub notes that an app always has at least read-only access to public repositories.
Read the permission list before you click Install. A deployment tool needs to read code; it should not need to write to it. For comparison, this is everything WharfCloud Deploy asks for:
| Permission | Access | Why |
|---|---|---|
| Repository contents | Read | To read your code and build it. Read only: we never push commits. |
| Metadata | Read | To list the repositories you chose and their branches. |
| Pull requests | Read | To know when a pull request opens, updates or closes, for previews. |
| Deployments | Read and write | To show each deployment and its URL on GitHub. |
| Commit statuses | Read and write | To mark each commit as building, ready or failed. |
| Members (organisation) | Read | To check that the person connecting an organisation is one of its admins. Never used to build or deploy. |
Doing it with WharfCloud Deploy
WharfCloud Deploy runs your projects on your own App Server in London and handles the proxy, certificates, builds and rollbacks above. The steps:
- 01
Order an App Server
Pick a size and pay by card. It is not instant: a person checks every first order, then we set up your App Server by hand, ready within 1 working day of approval.
- 02
Connect GitHub
Install the app and choose only the repositories you want to deploy.
- 03
Import the repository
We detect Next.js and suggest
next buildandnext start; change them if you need to, and set the root folder for a monorepo. - 04
Add environment variables
Set production and preview values separately and mark which are needed at build time, such as
NEXT_PUBLIC_variables. Values are encrypted so only your App Server can read them. - 05
Deploy
The first deploy takes minutes. Your app is live at an address like
shop.northwind.apps.wharfcloud.co.ukwith HTTPS. - 06
Keep pushing
Each push to the production branch deploys again. Each pull request gets a preview such as
pr-12-shop.northwind.apps.wharfcloud.co.uk, stopped after 7 days without a push and removed when the pull request closes. - 07
Add your domain
Create the TXT record shown in the panel (for example
_wharfcloud-verify.www.example.co.uk), point the domain at your App Server, and the certificate follows automatically.
WharfCloud Deploy does not include a managed database, and our support covers the platform rather than your application code. If you need both looked after, a Managed Linux Server may suit you better.
Sources
- Next.js: Deploying (deployment options and feature support) (opens in a new tab)
- Next.js: How to self-host your Next.js application (opens in a new tab)
- Next.js: output (standalone) (opens in a new tab)
- Next.js: How to use environment variables (opens in a new tab)
- Next.js: Static exports (unsupported features) (opens in a new tab)
- Next.js: Installation (system requirements) (opens in a new tab)
- GitHub Docs: Installing a GitHub App from a third party (opens in a new tab)
Facts were checked against these sources on 21 October 2026. Vendor terms change; check the source before relying on a detail.