Cloud & Deployment

Deploying to Vercel, Netlify & Railway

Ship your application to production using the platforms that handle infrastructure so you can focus on code.

Platform-as-a-Service

Platform-as-a-Service (PaaS) providers handle the infrastructure so you don't have to. No servers to configure, no Docker to write, no nginx to tune. You connect your GitHub repository and deployments happen automatically.

For most web applications, PaaS is the right choice.

Vercel

Vercel is built by the team that created Next.js. It is the natural home for Next.js applications.

What Vercel provides:

  • Zero-config deployment for Next.js (it just works)
  • Preview deployments — every pull request gets its own URL
  • Edge Network CDN — assets served from the closest location worldwide
  • Serverless functions (API routes) automatically
  • Environment variables UI with per-environment configuration
  • Analytics and Web Vitals monitoring
  • Custom domains with automatic SSL

Deployment configuration (vercel.json):

json
{
  "buildCommand": "npm run build",
  "outputDirectory": ".next",
  "regions": ["iad1"],
  "headers": [
    {
      "source": "/(.*)",
      "headers": [
        { "key": "X-Frame-Options", "value": "DENY" },
        { "key": "X-Content-Type-Options", "value": "nosniff" }
      ]
    }
  ]
}

Netlify

Netlify is similar to Vercel but more framework-agnostic. Excellent for any Jamstack or static site.

Where Netlify excels:

  • More flexible build environment (any Node.js version, multiple build tools)
  • Netlify Functions (AWS Lambda-based serverless functions)
  • Form handling built-in (no backend needed for simple forms)
  • Split testing (A/B testing for landing pages)
  • Identity management (authentication without custom code)

Netlify configuration (netlify.toml):

toml
[build]
  command = "npm run build"
  publish = ".next"

[[redirects]]
  from = "/*"
  to = "/index.html"
  status = 200

Railway

Railway is a full-stack PaaS that supports databases, background workers, and cron jobs alongside your web application — all in one platform.

Where Railway excels:

  • Deploy databases alongside your app (PostgreSQL, Redis, MySQL)
  • Background workers and cron jobs without separate services
  • Simple Docker-based deployment for any framework
  • Scales horizontally with simple configuration

Railway fills the gap between "just frontend" (Vercel/Netlify) and "full infrastructure" (AWS/GCP).

Decision Framework

NeedBest Choice
Next.js applicationVercel
Static site / Gatsby / HugoNetlify
Full-stack with databaseRailway
Need maximum controlAWS
Serverless API onlyVercel Functions or Railway

Preview Deployments

Preview deployments are one of the most powerful features of modern PaaS platforms. Every pull request gets its own deployment URL — https://my-app-pr-42.vercel.app.

Benefits:

  • Reviewers can see changes running in a real environment, not just reading code diffs
  • QA can test features before merge
  • Clients can preview changes before they go live
  • Bug reports can reference the specific preview URL

Key Takeaways

  • PaaS platforms (Vercel, Netlify, Railway) handle infrastructure automatically — connect GitHub and deploy
  • Vercel is the best choice for Next.js; preview deployments are included for every pull request
  • Railway is the right choice when you need a database + backend + workers in one platform
  • Configure environment variables per environment (development, preview, production) in the platform UI
  • Most Next.js applications do not need AWS — reach for it when you need specific services or maximum control

Example

json
// vercel.json — production configuration
{
  "buildCommand": "npm run build",
  "regions": ["iad1"],
  "headers": [
    {
      "source": "/(.*)",
      "headers": [
        { "key": "X-Frame-Options", "value": "DENY" },
        { "key": "X-Content-Type-Options", "value": "nosniff" },
        { "key": "Referrer-Policy", "value": "strict-origin-when-cross-origin" },
        { "key": "Strict-Transport-Security", "value": "max-age=31536000; includeSubDomains" }
      ]
    }
  ],
  "rewrites": [
    { "source": "/api/(.*)", "destination": "/api/$1" }
  ]
}
Try it yourself — JSON

Docker, AWS, Vercel, Netlify, GitHub, GitHub Actions are trademarks of Docker, Inc., Amazon.com, Inc., Vercel, Inc., Netlify, Inc., Microsoft Corporation. DevForge Academy is not affiliated with, endorsed by, or sponsored by these companies. Referenced for educational purposes only. See full disclaimers