How to host Next.js in 2025: VPS, self-hosting & managed options

Written by
Blog by Stephan Moerman
Stephan Moerman
Published on
Views
Reading time
10 min read
How to host Next.js in 2025: VPS, self-hosting & managed options

Let's say you have a Next.js app or website that you've just finished building, and now you have to make a decision. How am I going to host it so that other people can access it? There are a lot of options and these options have changed in the past few years. Nowadays you have even more options, and some of these options make self-hosting even more attractive, but lets zoom out and actually look at what the options are that you have. When reviewing these options it's not only about how easy it is to deploy, but it is also about how expensive it is and if all the features in a Next.js app are supported.

Managed hosting: a managed platform (like Vercel or Netlify)

One of your first and most straightforward options is to host the app on a managed platform, where a lot of things are taken care of for you. Some platforms that offer this type of solution are Vercel and Netlify, but there are others too. They are all about making it as easy as possible for you to get the app deployed, but also give you a lot of infrastructure and other features and so the whole deployment process is very smooth. With this option everything pretty much works out of the box, which makes it a compelling offer, but all of this does have a cost associated with it. One of the biggest benefits is that you'll be able to host your app and get it up and running within less than half an hour.

Self hosting: taking matters into our own hands

With self-hosting you're taking matters into your own hands, giving you more control over the hosting, deployment process, and this can be more cost effective in some circumstances. There is more friction generally speaking as you have to set everything up yourself, from scratch, but for some businesses this may be worth it.

Self hosting has changed as there are quite a lot of options nowadays. Some of these options include:

  • Static export
  • Plain Node.js application on a VPS
  • Dockerize on a VPS
  • Coolify / Dokploy on a VPS

VPS is just an example here, it can also be a dedicated server, however typically you won't need a whole dedicated server if you're just starting to build your app/start-up. With a VPS you don't have the entire server to yourself, but you share the hardware resources with other paying customers and get your virtualized piece of the hardware. Given that this is more efficient for most smaller businesses, it's more common for start-ups and businesses who want to keep their cost as low as possible. There are some sacrifices, but I'll cover that in another blog about hosting where we compare different cloud offerings (AWS, Azure, Google, etc.), VPS servers and dedicated servers.

Let's look at some of the options I mentioned earlier.

Creating and hosting a static export with Next.js

If I have a Next.js application, I can choose to start off with a static site or Single-Page Application (SPA), then later optionally upgrade to Server-Side Rendering (SSR) to use features that require a server.

To enable a static export, all you have to do is change the output mode inside next.config.js:

next.config.js
/**
 * @type {import('next').NextConfig}
 */
const nextConfig = {
  output: "export",
};
 
module.exports = nextConfig;

Once you've updated your config file, you can run npm run build, which will create an optimized production ready build. With a static export, what you'll essentially get is plain HTML, CSS and JavaScript files.

One thing to note is that there are quite a few server-side features that Next.js offers, that you won't be able to use. Read through the list of unsupported features here.

Typically you won't want to use Next.js if your goal is to make a very basic static website however, but you're able to take the static export and host it pretty much anywhere. The reason that we're using Next.js is partialy because it allows us to use these server-side features together with a front-end. This is why it's not very common to see static exports with Next.js applications. So if we can, we would still like to have that server-side capability.

Hosting Next.js using a plain Node.js VPS

A few years ago I started self-hosting some of my Next.js applications on a VPS. Although this works, it requires a lot of set-up and you'll have to be rather tech savvy to install all the required tooling such as Nginx, PM2, Certbot for your SSL certificates, GitHub CLI (gh) for your CI/CD pipeline. This also means that you'll havbe to work through some of the challenges that you will face.

Next.js can be deployed to any provider that supports Node.js, and on a VPS we can simply run a build with npm run build which will create a build. To then start the app you can use npm run start.

In most cases however you will want to avoid all this kind of setup as it also means the maintenance on your server is more time consuming. However, if you want to learn more about using Node.js on your VPS to run your Next.js application, you can find the relevant Next.js documentation here.

Deploying Next.js using Docker

One of my personal favorites is using Docker to deploy a Next.js application. Deploying as a Docker container makes you platform agnostic and portable. You have the capability of a “serverless” deployment with Docker on most of the cloud platforms. You can run the same build locally.

The pro is it is agnostic of the environment. You just need Docker on any machine you deploy to. The con is you have to mess about building images and you're tied to docker.

So when is Docker a good option? There are plenty of situations, but most often I find that when one of my clients already uses Docker, it's the easiest way to add a Next.js application to their tech stack. If you already have many Docker containers running, adding a new one is easier than using the Next.js deployment procedure (Vercel) to have complete DevOps control. Having Next.js running in a Docker container provides better security and dependability, faster and easier deployment procedures, and simpler application management.

This makes us think about how Docker is powerful. Docker doesn't care about the technology you use. It just works. With Docker, you can deploy ANY application, which is super powerful!

Using Coolify or Dokploy to host your Next.js application

If you're tired of complex deployment processes and just want to get your app online quickly, without relying on Vercel then Coolify or Dokploy are your best options. In the past year or so both Coolify and Dokploy have become increasingly popular.

Both Coolify and Dokploy give us a nice Admin panel where we can configure things. They also take care of some of the heavy lifting under the hood that you'd normally have to take care of yourself if you decide to use Docker or host on a plain Node.js VPS. With both Dokploy and Coolify, self-hosting on a VPS becomes much more realistic for a lot of people.

Let's take a look at how we can deploy Coolify to a VPS and lets see if all of the Next.js features still work on this VPS. One of the easiest ways to get started is using the Hostinger Coolify VPS Template. You get access to a Ubuntu 24.0.4 installation with Coolify (at the time of writing this blog post, the version may change as Ubuntu gets updated) so most of the installation is already done for you. There is a Dokploy template too, but I'll be going over the Coolify option as I have more experience and have extensively used Coolify in the recent year.

After you select the right plan for you, you'll be able to choose a Server OS in the next step. I ended up going for a KVM 2 server for demo purposes but you can choose to go for a beefier VPS too.

Hostinger VPS: Select Coolify as Operating System
Hostinger VPS: Select Coolify as Operating System

Once you've entered your billing details and selected the OS, you'll be able to set a root password and add an SSH key.

After a minute or so the VM will be up and running and you'll be able to click Manage panel. From here you'll be able to visit the IP address of your VPS and access your Coolify installation on the Hostinger VPS.

Click 'Manage panel' to access your Coolify installation
Click 'Manage panel' to access your Coolify installation

You'll get a warning as we haven't taken care of the SSL certificate yet, but we'll get to that in a second. After you click Continue to site you'll see the initial account creation screen for your Coolify Admin dashboard. It's important that you are the first one to actually access the VPS to make sure you create the root user.

Hostinger VPS: Select Coolify as Operating System
Hostinger VPS: Select Coolify as Operating System

Follow the short onboarding process, including choosing where you want to deploy your resources. To keep it simple, we'll run the Next.js application on the same server so we'll select Localhost here. Technically speaking they recommend hosting your Coolify installation on another server, but if it's a small app you can get away with running it on the same server perfectly fine.

Coolify onboarding: select localhost
Coolify onboarding: select localhost

Once done, you'll be taken to the Projects page to start your new project. Let's take a look at the Admin panel now.

Coolify Admin panel
Coolify Admin panel

With Coolify set up, you can now start hosting and deploying your applications. Whether you're using a pre-configured application stack or deploying via Git, Coolify makes it easy to manage your Next.js applications, as well as other apps and databases.

Now that you're ready to use Coolify to deploy your Next.js applications to your VPS, I'd recommend you watch this great video by ByteGrad to get started.

Conclusion

As you've seen, hosting a Next.js app in 2025 offers a wide range of options. From ultra-convenient managed platforms like Vercel, to full control with self-hosted Docker containers or tools like Coolify. Each route comes with trade-offs between cost, scalability, performance, and control.

If you're running a business and need to make the right infrastructure decisions without wasting weeks researching and configuring servers, I can help. As a fractional CTO, I work with startups and growing teams to set up scalable, modern infrastructure that fits their product goals and budget—whether that means going serverless, running on a VPS, or building a custom CI/CD pipeline.

Need someone to build your stack the right way from day one? Get in touch and let's make it happen.