🛵
BlogDocs

How to deploy a Next.js on your vps

Clément Chalopin

April 24, 2025

How to deploy a Next.js on your vps
Developer ToolsDeploymentDockerSelf-HostingDev ExperienceNext.jstypescript

How to deploy a Next.js app on your VPS

Next.js has become one of the most popular React frameworks for building modern web applications. With its server-side rendering capabilities, static site generation, and excellent developer experience, it's the go-to choice for many developers. However, deploying a Next.js application on your own VPS (Virtual Private Server) can sometimes be challenging.

What is Next.js?

Next.js is a React framework created by Vercel that enables developers to build fast, SEO-friendly web applications with features like:

  • Server-side rendering (SSR)
  • Static site generation (SSG)
  • Incremental Static Regeneration (ISR)
  • API Routes
  • Built-in CSS and Sass support
  • Automatic code splitting
  • TypeScript support

These features make Next.js an excellent choice for building modern web applications, from simple landing pages to complex e-commerce platforms.

The Simplest Way to Deploy Next.js on Your VPS

While there are several ways to deploy a Next.js application on your own VPS, the simplest and most efficient method is to use JustDeploy. JustDeploy streamlines the deployment process, handling all the complexities of server configuration, Docker setup, and continuous deployment.

Step-by-Step Guide to Deploy Next.js with JustDeploy

Let's walk through the complete process of deploying your Next.js application using JustDeploy on your VPS.

Step 1: Connect to your VPS via SSH

First, connect to your VPS using SSH. If you're using Linux or macOS, open your terminal and use the following command:

ssh username@your_server_ip

Replace username with your actual username and your_server_ip with your server's IP address.

Step 2: Install JustDeploy

Once connected to your server, install JustDeploy using the following command:

curl -fsSL https://get.justdeploy.app | bash

This command downloads and installs JustDeploy on your VPS, setting up everything you need to deploy your applications.

Step 3: Access the JustDeploy Dashboard

After installation, you can access the JustDeploy dashboard through your web browser by navigating to your server's IP address on port 5915:

http://your_server_ip:5915

Replace your_server_ip with your actual server IP address.

JustDeploy Dashboard

Step 4: Connect Your GitHub Account

To deploy your Next.js application, you'll need to connect JustDeploy to your GitHub account. In the JustDeploy dashboard:

  1. Click on the "Connect with GitHub" button
  2. Authorize JustDeploy to access your repositories
  3. Select the repositories you want to make available for deployment

GitHub Connection

Step 5: Select and Deploy Your Next.js Project

Now, it's time to deploy your Next.js application:

  1. From the dashboard, select the Next.js repository you want to deploy
  2. JustDeploy will automatically detect that it's a Next.js application
  3. Configure any necessary environment variables
  4. Click "Deploy"

That's it! JustDeploy will handle the rest, including setting up Docker containers, configuring Nginx, and setting up continuous deployment.

Project Selection and Deployment

What Happens Behind the Scenes?

When you deploy your Next.js app with JustDeploy, several things happen automatically:

  1. Docker container creation: JustDeploy creates a Docker container optimized for Next.js
  2. Build process: Your Next.js application is built with production optimizations
  3. Reverse proxy configuration: Nginx is set up to serve your application
  4. HTTPS setup: SSL certificates are automatically provisioned and renewed
  5. Continuous deployment: Any changes to your main branch will trigger automatic redeployment

Benefits of Using JustDeploy for Next.js Deployment

  • Simplicity: No need to manually configure servers or write complex Docker configurations
  • Performance: Optimized for production Next.js deployments
  • Security: Automatic HTTPS setup and updates
  • Scalability: Easy to scale as your application grows
  • Cost-effective: Use your own VPS instead of paying for expensive hosting services

Conclusion

Deploying a Next.js application on your own VPS doesn't have to be complicated. With JustDeploy, you can have your application up and running in minutes, with all the best practices implemented automatically. This approach gives you full control over your infrastructure while maintaining the simplicity of a managed service.

Try deploying your Next.js application with JustDeploy today, and experience the perfect balance between control and convenience.

Next Steps

After deploying your Next.js application, you might want to:

  • Set up custom domain names
  • Configure environment variables for different environments
  • Implement monitoring and logging
  • Set up CI/CD pipelines for testing before deployment

JustDeploy makes all of these steps straightforward, allowing you to focus on what matters most—building great applications.