Next.js Hosting
Vercel makes Next.js deployment simple - and charges accordingly as your traffic grows. Next.js does not require Vercel. The standalone output mode produces a Node.js server you deploy and manage like any other Node application: Nginx proxies traffic, PM2 or systemd keeps the process running, and your hosting cost is a flat monthly amount regardless of how many requests your application serves.
How Next.js runs on a VPS
Next.js has several output modes. The one that matters for VPS deployment is standalone. Add one line to your
next.config.js, run next build, and Next.js produces a self-contained Node.js server in
.next/standalone/ with all required dependencies traced and bundled. Start it with node .next/standalone/server.js, proxy it with Nginx, and manage it with PM2 or systemd. Every Next.js feature - SSR, API routes, Server Components, image optimization, Middleware - works exactly as documented.
output: 'standalone' - the correct production configuration
Add output: 'standalone' to the nextConfig object in your next.config.js. On the next build, Next.js traces all dependencies used by your application and copies only what's needed into .next/standalone/. The result is a minimal, self-contained directory you can deploy without shipping a full node_modules folder. Run it with node .next/standalone/server.js - no next start command, no Next.js CLI required on the server. Copy your public/ directory and .next/static/ alongside it to serve static assets correctly.
PM2 or systemd - process management
The standalone server is a standard Node.js process. PM2 keeps it running after you close your SSH session, restarts it on crash, and integrates with systemd for automatic startup on reboot. PM2 cluster mode spawns one worker per vCPU - useful for high-traffic applications where parallelising request handling across cores matters. Alternatively, a systemd unit file manages the process directly at the OS level without a separate process manager.
Nginx - reverse proxy, SSL, and static assets
Nginx listens on ports 80 and 443, handles SSL termination via Certbot and Let's Encrypt, and proxies requests to Next.js on port 3000. For better performance, configure a Nginx location block to serve /_next/static/ directly from the build output directory, bypassing the Node.js process entirely for static file requests. Your public/ directory can be served the same way. Configure Certbot once; renewal is automatic.
Image optimisation - next/image works on self-hosted deployments
Next.js's built-in image optimisation (next/image) runs on the Node.js server, optimising and resizing images on first request and caching the results. It works without any additional configuration on a self-hosted deployment. For best performance, add sharp to your project's dependencies before building - sharp is a faster image processing library that Next.js uses automatically if present. Without sharp, Next.js falls back to a slower built-in library.
Environment variables - server-side and client-side
Server-side environment variables are set in your server environment (via PM2's ecosystem file, systemd's Environment= directive, or a .env.local file in your project directory). Client-side variables - those exposed to the browser - must be prefixed with NEXT_PUBLIC_ and are baked into the build at next build time, not at runtime. If a client-side variable changes, you need to rebuild and redeploy, not just restart the server process.
The build step - next build before every deployment
Unlike a raw Node.js application where deployment is often just a git pull and process restart, Next.js requires a build step before the application can be served. next build compiles your React components, generates static pages, and creates the .next/ output directory. This step uses CPU and RAM - a large Next.js application can require 1-2GB of RAM during the build. Run the build on the server before restarting PM2, or build in a CI/CD pipeline and deploy the output directly.
Plans
Next.js SSR renders React on the server for every non-cached request - which is more memory-intensive than serving a static file or a simple API response. Plan sizing depends on your traffic volume, how much of your application is statically generated versus server-rendered, and whether you're running a database alongside Next.js.
| VPS-1 Low-traffic sites, mostly static pages, or development and staging environments | VPS-2 Most Next.js applications with SSR, API routes, and image optimisation - the recommended starting point | VPS-4 Higher-traffic applications, PM2 cluster across 4 cores, or large applications with heavy server-side rendering | VPS-6 High-traffic production workloads or multiple Next.js applications on one server | |
|---|---|---|---|---|
| vCPU | 1 | 2 | 4 | 6 |
| RAM | 1GB DDR5 | 2GB DDR5 | 4GB DDR5 | 8GB DDR5 |
| Storage | 25GB NVMe | 50GB NVMe | 100GB NVMe | 200GB NVMe |
| Bandwidth | 1TB | 2TB | 4TB | 6TB |
| IPv4 | 1 | 1 | 1 | 1 |
| Price | [price] | [price] | [price] | [price] |
| Deploy your VPS. | Deploy your VPS. | Deploy your VPS. | Deploy your VPS. |
These are renewal prices. What you pay today is what you pay next year.
All VPS plans are unmanaged. Bitfoo handles the hardware and network; your Next.js environment, build process, deployment workflow, and maintenance are your responsibility.
If your server exceeds its monthly bandwidth allocation, throughput is throttled for the remainder of the billing cycle - no additional charges.
Note on VPS-1 and builds: next build for a large application can require 1-2GB of RAM. On a 1GB
server, a large build may run out of memory. If this happens, build your application in CI/CD and deploy only
the .next/standalone/ output to the server. VPS-2 handles most production builds without issue.
Getting started
The standard deployment sequence for a Next.js application:
- Configure standalone output
Addoutput: 'standalone'to yournext.config.js. If you're using the App Router, this works without any other configuration changes. Addsharpto yourpackage.jsondependencies for faster image optimisation. - Order a VPS and install Node.js
Choose Ubuntu or Debian as your OS. Install Node.js via NVM - see the Node.js hosting page for the standard NVM installation steps. Next.js 14+ requires Node.js 18.17 or later; Next.js 15+ requires Node.js 18.18 or later. Check the Next.js release notes for the exact minimum version for your release. - Build your application
Clone your repository on the server (or deploy via CI/CD), install dependencies withnpm install, and runnext build. When the build completes, copypublic/into.next/standalone/and copy.next/static/into.next/standalone/.next/static/. These are required for static assets and thepublic/directory to be served correctly from the standalone output. - Start with PM2 and configure Nginx
Install PM2 globally (npm install -g pm2), start the standalone server (pm2 start .next/standalone/server.js --name your-app), and configure PM2 to start on boot (pm2 startupandpm2 save). Install Nginx, write a server block that proxies port 80 and 443 to port 3000, and use Certbot for Let's Encrypt SSL. Add a Nginx location block for/_next/static/to serve static assets directly.
What every VPS plan includes
Relevant features for Next.js, from the VPS hosting page:
Full root access and SSH from first boot - install Node.js, PM2, Nginx, and any database or supporting service your application uses
KVM virtualization - your own kernel; Node.js process management, PM2 cluster mode, and Nginx configuration work without host-imposed restrictions
AMD Ryzen 9 9900X - strong single-core performance for React server-side rendering; high clock speed reduces SSR latency per request
NVMe SSD storage - fast I/O for Next.js build output, static assets, and any database running on the same server
10Gbps network ports on all plans
IPv6 included on every plan
Self-service control panel - OS reinstall, power control, SSH key management, resource monitoring, and browser-based emergency console
99.9% uptime SLA - measured monthly, service credit issued for any shortfall
Automated provisioning - server ready within minutes of payment
5 datacenter locations at order time: US East, US West, UK, EU, Asia-Pacific
Who uses this
Next.js is one of the most widely deployed React frameworks - used for marketing sites, SaaS dashboards, e-commerce storefronts, and content-heavy applications. Self-hosting is typically driven by predictable pricing at scale, data residency requirements, or a preference for owning the infrastructure.
Developers · Agencies & freelancers · SaaS companies · Startups
Common questions
Do I need Vercel to run Next.js in production?
No. Vercel is one deployment option; a VPS is another. Next.js is an open-source framework - Vercel created it, but it runs on any Node.js server. The output: 'standalone' configuration in next.config.js produces a self-contained server that runs without the Vercel platform or any Vercel-specific tooling. Every core Next.js feature - SSR, API routes, Server Components, image optimisation, Middleware - works on a self-hosted deployment. The things that do not work outside Vercel are Vercel-specific features: Edge Functions using Vercel's edge runtime, Vercel Analytics, and Vercel's built-in CDN. None of those are part of the Next.js framework itself.
What is `output: 'standalone'` and do I need it?
You do not strictly need it - next start works without it - but standalone mode is the right choice for VPS deployments. Without it, your server needs the full node_modules directory present alongside the build output, which means either committing node_modules (not recommended) or running npm install on the server before each deployment. With output: 'standalone', Next.js traces every dependency your application actually uses and copies only those into .next/standalone/, along with a minimal server file. Deploy that directory and run node .next/standalone/server.js - no npm install, no Next.js CLI, no extra setup. Standalone output is also what makes CI/CD deployments cleaner: build in the pipeline, copy the output to the server, restart PM2. If you'd rather containerise a Next.js application, see the Docker hosting page.
Does image optimisation work when self-hosting Next.js?
Yes. Next.js's image optimisation (next/image) runs on the Node.js server, not on Vercel's infrastructure. When a visitor requests an optimised image for the first time, the Next.js server resizes and converts it, caches the result, and serves the cached version on subsequent requests. This works on any self-hosted deployment without additional configuration. For better performance, add sharp to your project's package.json dependencies before building - Next.js uses sharp for image processing when available, which is faster than its built-in fallback. Without sharp, optimisation still works, just more slowly.
How do I handle environment variables in self-hosted Next.js?
Next.js distinguishes between two types of environment variables. Server-side variables - accessible only in server components, API routes, and server-side functions - are set in your server environment via PM2's configuration file (env key), a systemd Environment= directive, or a .env.local file in your project directory. These are never exposed to the browser. Client-side variables - exposed to the browser at runtime - must be prefixed with NEXT_PUBLIC_ and are baked into the JavaScript bundle at next build time. If a NEXT_PUBLIC_ variable changes, you need to rebuild and redeploy; restarting the server process alone is not sufficient. Any variable without the NEXT_PUBLIC_ prefix is server-only regardless of where it's set.
How do I deploy updates to my Next.js application?
The standard update workflow for a self-hosted Next.js application: pull your new code, run npm install if dependencies changed, run next build, copy the updated public/ and .next/static/ into the standalone output directory, then restart PM2 (pm2 restart your-app). The application is briefly unavailable during the restart - typically a few seconds. For zero-downtime deployments, PM2's reload command (rather than restart) performs a graceful rolling reload: new workers start before old ones stop, so there's no gap in availability. For more complex deployment pipelines, building in CI/CD and deploying only the .next/standalone/ output avoids running the build on the production server entirely.
Do API routes and Server Components work when self-hosting?
Yes, without any additional configuration. API routes (/api/ in the Pages Router, route.ts or route.js files in the App Router) run as part of the Next.js Node.js server and work identically to a Vercel deployment. Server Components render on the Node.js process. Middleware runs on the Node.js process in self-hosted mode - note that Next.js Middleware is designed to run on Vercel's edge runtime, but it runs on the standard Node.js runtime when self-hosted, which means the Edge runtime API restrictions (no fs, limited Node.js APIs) do not apply. The practical implication: middleware that uses Node.js-only APIs works in self-hosted mode but would fail on Vercel's edge runtime.
Which plan should I choose for Next.js?
The primary consideration is how much server-side rendering your application does and whether you're running a database on the same server. VPS-1 suits low-traffic sites with mostly statically generated pages, or staging and development environments. VPS-2 is the recommended starting point for most Next.js applications in production - it handles SSR, API routes, image optimisation, and a moderate-traffic site without running close to memory limits. Note that next build for a large application can use 1-2GB of RAM; if builds fail on VPS-1, either upgrade to VPS-2 or build in CI/CD and deploy only the output. VPS-4 suits higher-traffic applications or those where PM2 cluster mode across 4 cores meaningfully improves throughput. VPS-6 suits large-scale deployments or servers running multiple Next.js applications. When in doubt, start on VPS-2 - upgrading is straightforward and does not require migrating data.