SwiftAcademy Logo

Navigation

How to Deploy a Next.js Application on Vercel: Zero to Production in 15 Minutes

Published Apr 01 2026Updated Mar 22 2026
How to Deploy a Next.js Application on Vercel: Zero to Production in 15 Minutes

Deploying a web application used to mean wrestling with servers, configuring nginx, managing SSL certificates, and spending hours debugging obscure deployment errors. With Vercel and Next.js, deployment takes approximately 15 minutes, and most of that time is spent waiting for builds. Vercel was created by the same team that built Next.js, which means the deployment experience is deeply integrated and optimized. For developers in Nepal, this means you can focus on building great applications instead of managing infrastructure, and you can deploy projects to share with clients, employers, and users worldwide without spending a single rupee on hosting for hobby and portfolio projects. This guide walks you through every step from a local Next.js project to a production URL.

Why Is Vercel the Best Platform for Deploying Next.js?

Vercel is the best platform for Next.js because it was built by the same team, offers zero-configuration deployment, automatically optimizes server-side rendering and static generation, provides a generous free tier, and delivers content through a global edge network.

The relationship between Next.js and Vercel is like the relationship between Android and Google. While you can deploy Next.js elsewhere, Vercel offers the most optimized experience:

Feature Vercel Netlify AWS Amplify Railway
Next.js SSR Support Full native Partial Partial Full
Zero Config Deployment Yes Mostly No Mostly
Edge Functions Yes (native) Yes Yes No
Image Optimization Built-in Third-party Manual Manual
ISR Support Full Partial Partial Full
Preview Deployments Every PR Every PR Every PR Manual
Free Tier Generous Generous Limited Limited
Global CDN Yes (edge) Yes Yes (CloudFront) Single region

The key advantages in detail:

Zero configuration. Push your code to GitHub and Vercel detects your Next.js project automatically. It configures the build command, output directory, and routing without any setup files.

Preview deployments. Every pull request gets its own deployment URL. This lets you share work-in-progress with clients or team members before merging to production. For freelancers in Nepal working with international clients, this feature alone saves hours of communication.

Edge network. Vercel deploys your application to edge nodes worldwide. A user in Japan, a client in the US, and you in Pokhara all get fast response times because the content is served from the nearest edge location.

Automatic HTTPS. Every deployment gets a free SSL certificate automatically. No configuration, no renewal management, no cost.

How Do You Prepare a Next.js Project for Deployment?

Prepare your Next.js project by ensuring it builds without errors locally, configuring environment variables, optimizing images with next/image, setting up proper metadata, and verifying that all API routes and server components work correctly.

Before deploying, complete this checklist:

Step 1: Verify your project builds successfully

npm run build

This command must complete without errors. Common build issues to fix:

// Fix: Import images correctly for production
import Image from 'next/image';

// Good - uses Next.js Image component
<Image src="/hero.jpg" alt="Hero image" width={800} height={400} />

// Bad - direct img tag misses optimization
<img src="/hero.jpg" alt="Hero image" />

Step 2: Set up environment variables

Create a .env.local file for local development (never commit this to Git):

# .env.local
DATABASE_URL=postgresql://user:password@localhost:5432/mydb
NEXT_PUBLIC_API_URL=https://api.example.com
NEXT_PUBLIC_SITE_URL=https://yourdomain.com
SECRET_API_KEY=your-secret-key-here

Important: Variables prefixed with NEXT_PUBLIC_ are exposed to the browser. Never prefix secret keys with NEXT_PUBLIC_.

Step 3: Add a proper .gitignore

# .gitignore
node_modules/
.next/
.env.local
.env*.local
out/

Step 4: Configure metadata for SEO

// app/layout.tsx
import type { Metadata } from 'next';

export const metadata: Metadata = {
  title: {
    default: 'Swift Academy - IT Training in Pokhara',
    template: '%s | Swift Academy',
  },
  description: 'Learn Flutter, Next.js, Django, and Laravel at Swift Academy, Pokhara.',
  openGraph: {
    type: 'website',
    locale: 'en_US',
    url: 'https://swiftacademy.com.np',
    siteName: 'Swift Academy',
  },
};

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>{children}</body>
    </html>
  );
}

Step 5: Push your code to GitHub

git init
git add .
git commit -m "Initial commit - ready for deployment"
git remote add origin https://github.com/yourusername/your-project.git
git push -u origin main

How Do You Deploy to Vercel Step by Step?

Deploy to Vercel by creating a Vercel account, importing your GitHub repository, configuring environment variables in the Vercel dashboard, clicking deploy, and receiving your production URL within 2-3 minutes.

Here is the complete deployment process:

Step 1: Create a Vercel account

Go to vercel.com and sign up with your GitHub account. This is the easiest option because it automatically connects your repositories.

Step 2: Import your project

Click "Add New" then "Project" on the Vercel dashboard. You will see a list of your GitHub repositories. Select the repository you want to deploy.

Step 3: Configure the project

Vercel automatically detects that it is a Next.js project and fills in the correct settings:

  • Framework Preset: Next.js (auto-detected)
  • Root Directory: ./ (unless your Next.js app is in a subdirectory)
  • Build Command: next build (auto-detected)
  • Output Directory: .next (auto-detected)

Step 4: Add environment variables

In the "Environment Variables" section, add each variable from your .env.local file. Do not add the NEXT_PUBLIC_ prefix variables if the values should differ between local and production:

DATABASE_URL = your-production-database-url
SECRET_API_KEY = your-production-api-key
NEXT_PUBLIC_API_URL = https://api.yourdomain.com
NEXT_PUBLIC_SITE_URL = https://yourdomain.com

Step 5: Click Deploy

Click the "Deploy" button and wait. Vercel will:

  1. Clone your repository
  2. Install dependencies (npm install)
  3. Run the build command (next build)
  4. Deploy the output to its edge network

Typical build times are 1-3 minutes for small to medium projects.

Step 6: Access your live site

Once deployment completes, Vercel provides a URL like your-project.vercel.app. Your application is now live and accessible worldwide.

How Do You Set Up a Custom Domain on Vercel?

Setting up a custom domain on Vercel involves adding the domain in the Vercel project settings, then updating your domain's DNS records to point to Vercel's servers, with SSL certificates provisioned automatically within minutes.

For professional projects and clients, you will want a custom domain instead of the default .vercel.app URL.

Step 1: Add the domain in Vercel

Go to your project settings, click "Domains", and enter your domain name (e.g., swiftacademy.com.np).

Step 2: Configure DNS records

Vercel will show you the DNS records to add. For most domains, you need:

Type: A
Name: @
Value: 76.76.21.21

Type: CNAME
Name: www
Value: cname.vercel-dns.com

Add these records in your domain registrar's DNS management panel (GoDaddy, Namecheap, or your Nepali domain registrar for .com.np domains).

Step 3: Wait for DNS propagation

DNS changes typically take 5 minutes to 48 hours to propagate worldwide. For .com.np domains registered through Nepali registrars, this usually completes within a few hours.

Step 4: Verify SSL

Vercel automatically provisions a free SSL certificate once DNS is verified. Your site will be accessible via HTTPS within minutes of DNS propagation completing.

For Nepali developers registering .com.np domains, Mercantile Communications and other local registrars support the DNS record types that Vercel requires. If you use .com or .net domains from international registrars like Namecheap, the process is even simpler.

How Do You Handle Environment Variables and Secrets on Vercel?

Vercel manages environment variables through its dashboard with separate values for Production, Preview, and Development environments, ensuring secrets never appear in client-side code or version control.

Proper environment variable management is crucial for security:

// lib/config.ts - Type-safe environment variable access
function getEnvVar(key: string): string {
  const value = process.env[key];
  if (!value) {
    throw new Error(`Missing environment variable: ${key}`);
  }
  return value;
}

export const config = {
  databaseUrl: getEnvVar('DATABASE_URL'),
  apiSecret: getEnvVar('SECRET_API_KEY'),
  publicApiUrl: process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3000/api',
};

Environment variable scoping on Vercel:

Variable Type Available Where Example
Regular (server-only) Server components, API routes, middleware DATABASE_URL
NEXT_PUBLIC_ prefixed Both server and client NEXT_PUBLIC_SITE_URL
Production only Production deployments Sensitive API keys
Preview only PR preview deployments Staging database URL
Development only Local development Local API endpoints

Vercel lets you set different values for each environment. This means your production deployment can connect to a production database while preview deployments use a staging database, without any code changes.

# Using Vercel CLI to manage env vars
npm i -g vercel

# Add a secret
vercel env add DATABASE_URL production

# Pull env vars for local development
vercel env pull .env.local

How Do You Set Up Continuous Deployment With Vercel?

Vercel provides automatic continuous deployment by default: every push to your main branch triggers a production deployment, and every pull request creates a preview deployment with its own unique URL.

Once your project is connected to GitHub, continuous deployment works automatically:

Push to main branch → Production deployment (yourdomain.com)
Push to any branch → Preview deployment (unique-url.vercel.app)
Create a pull request → Preview deployment linked in PR comments

You can customize this behavior in your project settings:

// vercel.json - Optional configuration
{
  "buildCommand": "npm run build",
  "framework": "nextjs",
  "regions": ["sin1"],
  "headers": [
    {
      "source": "/api/(.*)",
      "headers": [
        {
          "key": "Cache-Control",
          "value": "no-store, max-age=0"
        }
      ]
    }
  ],
  "redirects": [
    {
      "source": "/old-page",
      "destination": "/new-page",
      "permanent": true
    }
  ]
}

For team projects, the preview deployment workflow is particularly powerful:

  1. Developer creates a feature branch and pushes changes
  2. Vercel automatically creates a preview deployment
  3. The preview URL is posted as a comment on the GitHub pull request
  4. Team members and clients can review the changes on the preview URL
  5. When the PR is merged, the production deployment updates automatically

This workflow eliminates the need for staging servers, manual deployment scripts, or complex CI/CD pipelines. For small teams and freelancers in Nepal, this simplicity is transformative.

What Are Common Deployment Issues and How Do You Fix Them?

Common Vercel deployment issues include build failures from missing environment variables, TypeScript errors ignored locally, image optimization limits on free tier, and API route timeouts, all solvable with proper configuration.

Here are the most frequent deployment problems and their solutions:

Problem 1: Build fails with missing module errors

# Error: Module not found: Can't resolve 'some-package'
# Fix: Ensure all dependencies are in package.json, not devDependencies
npm install some-package --save

Problem 2: TypeScript errors that did not appear locally

// Vercel runs strict builds. Fix all TypeScript errors.
// Common fix: Add proper types instead of 'any'

// Bad
const handleSubmit = (data: any) => { ... }

// Good
interface FormData {
  name: string;
  email: string;
}
const handleSubmit = (data: FormData) => { ... }

Problem 3: Environment variables not available

// If you see 'undefined' for env vars, check:
// 1. Variable is added in Vercel dashboard
// 2. Variable name matches exactly (case-sensitive)
// 3. For client-side access, prefix with NEXT_PUBLIC_
// 4. Redeploy after adding new env vars

// Server component - can access all env vars
const dbUrl = process.env.DATABASE_URL; // works

// Client component - only NEXT_PUBLIC_ vars
const apiUrl = process.env.NEXT_PUBLIC_API_URL; // works
const secret = process.env.SECRET_KEY; // undefined in browser

Problem 4: API routes timing out

// Vercel has a 10-second timeout on the free tier for serverless functions
// Fix: Optimize your API routes or upgrade to Pro

// app/api/data/route.ts
export const maxDuration = 10; // Set max duration (Pro plan allows up to 300)

export async function GET() {
  // Keep operations fast
  const data = await fetchDataWithTimeout(8000); // Leave buffer
  return Response.json(data);
}

Problem 5: Large deployment size

// next.config.js - Optimize output
/** @type {import('next').NextConfig} */
const nextConfig = {
  output: 'standalone', // Reduces deployment size
  images: {
    formats: ['image/avif', 'image/webp'],
  },
};

module.exports = nextConfig;

What the Reddit Community Says

Vercel deployment discussions on Reddit are overwhelmingly positive for Next.js projects. On r/nextjs, one popular comment captures the community sentiment: "I deployed my first Next.js project to Vercel in literally 3 clicks. Coming from configuring AWS manually, it felt like magic." Users frequently praise the preview deployment feature for client work: "I send my client a preview URL for every change. They review it, I make adjustments, and when approved I merge to main. Vercel handles everything."

On r/webdev, the main criticism of Vercel is vendor lock-in and pricing at scale. However, most commenters agree that for personal projects, freelance work, and small to medium applications, the free tier is more than sufficient. One user noted: "I have 6 projects on Vercel's free tier. None of them have hit any limits. For hobby and portfolio projects, it is genuinely free."

In r/Nepal, developers share tips about using Vercel for portfolio projects: "Put all your projects on Vercel with custom subdomains. When you send a portfolio to an employer, they can actually visit and interact with your projects instead of just seeing screenshots. This makes a huge difference in the Nepali job market where many candidates only show static portfolio images."

Practical Takeaway

Here is your deployment checklist to go from local to production in 15 minutes:

  1. Minute 0-2: Run npm run build locally and fix any errors.
  2. Minute 2-4: Push your code to a GitHub repository.
  3. Minute 4-6: Sign up or log in to Vercel and import your repository.
  4. Minute 6-8: Add environment variables in the Vercel dashboard.
  5. Minute 8-10: Click Deploy and wait for the build to complete.
  6. Minute 10-13: Test your live site, checking all pages and features.
  7. Minute 13-15: (Optional) Add a custom domain and configure DNS.

Every Next.js project you build should be deployed. A live URL is worth ten times more than a GitHub repository link when applying for jobs or pitching to clients. Make deployment a habit, not an afterthought.

Frequently Asked Questions

Is Vercel free for personal projects?

Yes. Vercel's Hobby plan is free and includes unlimited personal projects, 100GB bandwidth per month, automatic SSL, and preview deployments. This is more than sufficient for portfolios, learning projects, and small client sites.

Can I deploy a Next.js app without Vercel?

Yes. You can deploy Next.js to Netlify, AWS Amplify, Railway, DigitalOcean, or any platform that supports Node.js. However, Vercel provides the most optimized experience for Next.js, especially for features like ISR and server components.

How do I handle databases with Vercel deployment?

Vercel does not include databases, but it integrates with services like Vercel Postgres, PlanetScale, Supabase, and Neon. For Nepali developers, Supabase's free tier is an excellent choice for getting started with a PostgreSQL database.

Does Vercel work with .com.np domains?

Yes. You can use any domain with Vercel, including .com.np domains registered through Nepali registrars. You just need to update your DNS records to point to Vercel's servers.

What happens if my Vercel project exceeds free tier limits?

Vercel will notify you before any charges. If you exceed bandwidth or build limits, your deployments may be paused until the next billing cycle. For most portfolio and small projects, you will never reach these limits.

Learn Next.js Deployment and More at Swift Academy

Deployment is just one part of becoming a production-ready Next.js developer. Swift Academy's Next.js course in Pokhara at NPR 16,000 covers everything from React fundamentals through advanced Next.js features, Tailwind CSS styling, API development, and production deployment on Vercel. Build real, deployed projects that you can show to employers and clients. Visit swiftacademy.com.np or come to our Pokhara campus.

Related Articles

Suggested Images

  1. Alt: "Vercel deployment dashboard showing successful Next.js build with production URL and deployment details"
  2. Alt: "Step by step diagram showing the flow from local Next.js development to GitHub push to Vercel deployment"
  3. Alt: "Vercel custom domain configuration screen showing DNS settings for a .com.np Nepali domain"

Related Posts

How to Deploy a Next.js Application on Vercel: Zero to Production in 15 Minutes - Swift Academy