Menu

Deploying to Vercel and Other Platforms

Lesson 2: Deploying to Vercel and Other Platforms

Where can you deploy Next.js?

Option Setup effort Supports all features Notes
Vercel Very low Yes Made by the Next.js team; previews per pull request
Netlify, Cloudflare, AWS Amplify, others Low–medium Depends on the platform's adapter Check the platform's Next.js support notes
Your own Node.js server / VPS Medium Yes Full control; you manage scaling
Docker on any container host Medium Yes Portable across clouds
Static hosting (output: 'export') Low No (no server features) Only for fully static sites

Next.js 16 introduced a Build Adapters API so hosting platforms can integrate with the build process in a standard way.

Example: Vercel

  1. Push your project to GitHub, GitLab, or Bitbucket.
  2. Import the repository in the Vercel dashboard. Next.js is detected automatically.
  3. Add environment variables (DATABASE_URL, BETTER_AUTH_SECRET) for Production and Preview.
  4. Deploy. Every push to main updates production; every pull request gets its own preview URL.
# Or deploy from the terminal
npm i -g vercel
vercel        # Preview deployment
vercel --prod # Production deployment

How it works

  • Static pages and assets are served from a global CDN.
  • Dynamic routes, Server Actions, and Route Handlers run as serverless functions.
  • Cache invalidation (updateTag, revalidateTag) works across all regions automatically.
  • Preview deployments let reviewers test changes before they reach users.

Common mistakes

Mistake Effect Fix
Using the production database for previews Test data mixes with real data Use a separate database or branch for previews
Forgetting to add env vars on the platform Build or runtime errors Mirror .env.local keys in the platform settings
Database in a different region from functions Slow responses Put functions and database in the same region

Key takeaways

  • Managed platforms give you CDN, functions, and previews with almost no setup.
  • Check each platform's adapter support for features you rely on, such as ISR and Cache Components.

Try it: Deploy LearnHub to Vercel, open a pull request, and share its preview URL.


Nextjs Tutorial

J

Jebasta





Get in Touch For Details