GitHub|Since 2007
Step 5

Hosting Options: Vercel, VPS, Docker

Where will you host your Next.js project? Compare options like Vercel, Netlify, self-hosting, or Docker-based deployments.

12 min

Hosting Options

There are several ways to run your Next.js application. Your choice depends on your budget, technical skills, and specific needs.

Option 1: Vercel (Easiest)

Vercel is the platform created by the developers of Next.js. It works with zero configuration.

Pros:

  • ✅ Free plan (sufficient for hobby projects)
  • ✅ Automatic deployment on GitHub push
  • ✅ Global CDN (fast access worldwide)
  • ✅ Automatic and free SSL certificates
  • ✅ No server management required

Cons:

  • ❌ Paid for commercial use (starts at $20/month)
  • ❌ Less control over the underlying server

Setup:

  1. Go to vercel.com
  2. Log in with "Continue with GitHub"
  3. Select your repository and Deploy!

Option 2: Netlify (Vercel Alternative)

Netlify is a platform very similar to Vercel.

Pros:

  • ✅ Free plan available
  • ✅ Extra features like form handling and identity management
  • ✅ Seamless GitHub integration

Setup:

  1. Go to netlify.com
  2. Connect with GitHub
  3. Build command: npm run build
  4. Publish directory: .next

Option 3: VPS + Docker (Full Control)

You can run Next.js with Docker on your own server. This provides the most control.

Requirements:

  • VPS (DigitalOcean, Hetzner, Contabo, etc.)
  • Ubuntu 22.04 or higher
  • At least 1GB RAM, 1 vCPU

Step 1: Connect to Your Server

ssh root@YOUR_SERVER_IP

Step 2: Install Docker

# Install Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh

# Install Docker Compose
apt install docker-compose -y

Step 3: Create a Dockerfile

Create a Dockerfile in your project root:

FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"]

Step 4: docker-compose.yml

version: '3'
services:
  nextjs:
    build: .
    ports:
      - '3000:3000'
    environment:
      - WORDPRESS_API_URL=https://example.com/wp-json/wp/v2
    restart: always

Step 5: Launch

docker-compose up -d --build

Your site is now live at http://YOUR_SERVER_IP:3000!

Step 6: Nginx + SSL (Recommended)

# Install Nginx
apt install nginx -y

# Install Certbot (SSL)
apt install certbot python3-certbot-nginx -y

Nginx config (/etc/nginx/sites-available/default):

server {
    server_name example.com;
    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}
# Get SSL certificate
certbot --nginx -d example.com

Which Option Should I Choose?

ScenarioRecommended
I want to start as fast as possibleVercel
Commercial project with a budgetVercel Pro
I want full control and custom server logicVPS + Docker
Very tight budgetVPS ($5/month)

Comments and Discussion