Architectural cost comparison of hosting Next.js 15: Vercel Pro ($20/seat + overages) vs self-hosted Coolify on Hetzner ($14.50/mo) vs Cloudflare Pages OpenNext.
FROM node:20-alpine AS base
FROM base AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
ENV NEXT_TELEMETRY_DISABLED=1
RUN npm run build
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV PORT=3000
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
EXPOSE 3000
CMD ["node", "server.js"]
Next.js is the dominant React framework for modern full-stack web applications, but hosting it on Vercel can lead to severe bill shock once traffic scales. Vercel charges $0.15/GB for bandwidth overages ($150 per TB) and $0.40 per 1M edge middleware invocations, turning viral marketing events or web-scraping bot waves into multi-thousand-dollar invoices.
Modern alternatives allow self-hosting standalone Next.js Docker containers via Coolify on Hetzner Cloud or deploying serverless Next.js directly onto AWS via SST Ion (OpenNext), delivering identical performance at up to 90% lower infrastructure cost.
| Hosting Strategy | Base Platform Fee | Bandwidth Cost (5TB) | Serverless Compute | Total Monthly Bill |
|---|---|---|---|---|
| Vercel Pro | $20 / team member / mo | $600.00 (4TB overage @ $0.15/GB) | $160.00 (Fast Origin Compute) | $780.00 / month |
| Hetzner Cloud + Coolify (Self-Hosted) | $0.00 (Open-source PaaS) | $0.00 (20TB included free) | $15.20 / mo (CPX31: 4 vCPU, 8GB RAM) | $15.20 / month (98% Savings) |
| AWS via SST Ion (OpenNext) | $0.00 (Pure AWS primitives) | $425.00 (CloudFront @ $0.085/GB) | $45.00 (AWS Lambda ARM64) | $470.00 / month |
| Cloudflare Pages + Workers | $5.00 / mo (Workers Paid) | $0.00 (Unlimited free egress) | $15.00 (CPU time overages) | $20.00 / month |
# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
# Production runner stage (Minimal 120MB image)
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
EXPOSE 3000
CMD ["node", "server.js"]
When running Next.js Docker containers via Coolify or Kamal on Hetzner or DigitalOcean, configuring rolling zero-downtime deployments ensures user sessions are never interrupted. Traefik reverse proxies route inbound HTTPS traffic to healthy container replicas before retiring older builds, delivering the exact same seamless deployment workflow as Vercel Git pushes without the unmetered bandwidth overage tax.
When running standalone Next.js in production outside Vercel, the primary architectural challenge is managing image optimization and dynamic caching. While Vercel handles Next.js Image Optimization via serverless edge functions ($5.00 per 1,000 source images after the free tier), self-hosted Next.js uses the sharp library directly inside the Docker container.
Security & Environment Secrets Notice: When deploying standalone Next.js on Coolify or Docker Swarm, always encrypt production secrets using HashiCorp Vault, Doppler, or Coolify's built-in encrypted secrets vault. Never hardcode `.env.production` files directly inside your public Docker image build layers or Git repository commits.
Edge Image Optimization with Cloudflare Workers: Offload responsive image resizing from self-hosted Next.js containers to Cloudflare Images or edge worker scripts, freeing up container CPU cores to handle dynamic database operations without latency degradation.