’xR—

How to Deploy a Next.js Website on Vercel

The complete beginner-to-intermediate guide — from creating your first Next.js app to going live with a custom domain, environment variables, and automatic CI/CD deployments.

G-Tech Blog  |  2026  |  15 min read

Deploying a website used to mean wrestling with servers, configuring nginx, managing SSL certificates, and dealing with hosting bills. Vercel changed all of that. Built by the same team that created Next.js, Vercel is a cloud platform designed specifically for frontend and full-stack web applications — and for Next.js projects in particular, the deployment experience is as close to magic as web development gets. In this guide, you will go from zero to a live, production-ready Next.js website, completely free, with automatic deployments every time you push code to GitHub.

Why Vercel for Next.js?

Vercel was founded by Guillermo Rauch, who also created Next.js. This means the platform is not just compatible with Next.js — it is built around it. Features that require significant server configuration on other hosting platforms work automatically on Vercel: server-side rendering (SSR), static site generation (SSG), incremental static regeneration (ISR), API routes, edge functions, image optimization, and middleware all work out of the box with zero configuration.

What Vercel gives you for free

  • Unlimited personal projects on the Hobby plan
  • Automatic HTTPS/SSL certificates on every deployment
  • Global CDN across 100+ edge locations worldwide
  • Automatic preview deployments for every Git branch and pull request
  • Built-in CI/CD — push to GitHub, Vercel deploys automatically
  • Custom domain support with automatic DNS configuration
  • Vercel Analytics (basic) and Speed Insights
  • Serverless function support for API routes

Why developers choose Vercel over alternatives

  • Zero configuration — Vercel detects Next.js automatically and configures everything correctly
  • Instant deployments — most projects deploy in 30—90 seconds
  • Preview URLs — every branch gets its own live URL for testing
  • Edge network — your site is served from the closest location to each visitor
  • First-class SSR support — unlike purely static hosts, Vercel handles server-rendered pages natively
  • Excellent free tier — sufficient for personal projects, portfolios, and small apps

For a student, developer building a portfolio, or team launching an MVP, Vercel's free Hobby plan provides everything needed to run a production-quality website. You do not need a credit card to sign up, and the free tier does not expire after a trial period.

Prerequisites and What You Need

Before you start, make sure you have the following in place. Don't skip this section — each item is genuinely required to follow the steps below.

You do not need prior experience with Next.js to follow this guide. If you have built a website with React before, Next.js will feel familiar immediately. If you are completely new to both, this guide will still work — just focus on the deployment steps and explore the Next.js framework at your own pace after your site is live.

Step 1: Install Node.js and npm

Node.js is the JavaScript runtime that powers Next.js development. npm (Node Package Manager) is included with Node.js and is used to install packages and run project scripts. You need both installed before you can create or run a Next.js project.

Check if Node.js is already installed

Open your terminal (Terminal on macOS/Linux, Command Prompt or PowerShell on Windows) and run:

node -v

If you see a version number like v20.11.0, Node.js is installed. Also check npm:

npm -v

If you see a version number for both, skip to Step 2. If you get a "command not found" error, continue below.

Install Node.js

Go to nodejs.org and download the LTS (Long Term Support) version — this is the stable, recommended version for most users. Run the installer and follow the prompts. Once installation finishes, close and reopen your terminal, then verify with node -v and npm -v again.

Alternatively, if you use a package manager:

# macOS with Homebrew
brew install node

# Ubuntu / Debian Linux
sudo apt update
sudo apt install nodejs npm

# Windows with winget
winget install OpenJS.NodeJS.LTS
If you manage multiple Node.js projects with different version requirements, consider using nvm (Node Version Manager) instead of installing Node directly. NVM lets you switch between Node versions easily: nvm install 20 then nvm use 20.

Step 2: Create a Next.js Project

Next.js provides an official scaffolding tool called create-next-app that sets up a complete, production-ready project structure in seconds. You do not need to install it separately — npx (included with npm) downloads and runs it automatically.

Create your project

In your terminal, navigate to the folder where you want to create the project (e.g. your Desktop or a Projects folder), then run:

npx create-next-app@latest my-website

The installer will ask you several setup questions. Here are the recommended answers for a beginner:

Would you like to use TypeScript? ⬺ No (or Yes if you know TypeScript)
Would you like to use ESLint? ⬺ Yes
Would you like to use Tailwind CSS? ⬺ Yes (optional, but very useful)
Would you like to use the `src/` directory? ⬺ No
Would you like to use App Router? ⬺ Yes (recommended)
Would you like to customize the default import alias? ⬺ No

Run the development server

Navigate into your new project folder and start the local development server:

cd my-website
npm run dev

Open your browser and go to http://localhost:3000. You should see the default Next.js welcome page with an animated logo — your project is running locally. The development server supports hot reloading, meaning changes you save in your code editor appear instantly in the browser without refreshing.

To stop the development server, press Ctrl + C in the terminal. You'll need to run npm run dev again each time you want to work on your project locally. The server only needs to run when you are actively developing — you do not need it running for your deployed Vercel site to work.

Step 3: Explore Your Project Structure

Before pushing to GitHub, take a few minutes to understand what create-next-app generated. Knowing your project structure makes it much easier to customize your site and debug problems later.

Key files and folders explained

  • app/ — The App Router directory. Each folder becomes a route. app/page.tsx is your homepage. app/about/page.tsx would be /about.
  • app/layout.tsx — The root layout that wraps every page. This is where you add global fonts, metadata, headers, and footers.
  • public/ — Static assets like images, icons, and fonts. Files here are accessible at the root URL (e.g. public/logo.png —  /logo.png).
  • package.json — Lists all your project's dependencies and scripts. Don't delete this file.
  • next.config.js (or .mjs) — Configuration file for Next.js. You can enable experimental features, configure image domains, set redirects, and more here.
  • .gitignore — Tells Git which files not to track. The node_modules folder and .env.local file are excluded by default — this is correct and important.
  • node_modules/ — All installed packages. This folder is large (100MB+) and should never be committed to Git — it is regenerated by running npm install.

Step 4: Push Your Project to GitHub

Vercel deploys from Git repositories. GitHub is the most popular option and integrates most smoothly with Vercel. You need to create a GitHub repository for your project and push your code to it before Vercel can deploy it.

Create a new GitHub repository

  1. Go to github.com and sign in to your account.
  2. Click the + button in the top-right corner and select New repository.
  3. Give the repository a name (e.g. my-website). It can be the same as your project folder name.
  4. Set the visibility to Public or Private — both work with Vercel on the free plan.
  5. Do not check "Add a README file," "Add .gitignore," or "Choose a license" — your project already has these. Adding them here will cause a merge conflict.
  6. Click Create repository.

GitHub will show you a page with setup instructions. Copy the URL of your new repository — it will look like https://github.com/yourusername/my-website.git.

Push your project to GitHub

Open your terminal inside your project folder and run these commands one at a time:

# Initialize a Git repository (if not already initialized)
git init

# Stage all files for the first commit
git add .

# Create your first commit
git commit -m "Initial commit"

# Rename the default branch to 'main'
git branch -M main

# Connect your local repo to the GitHub repo
git remote add origin https://github.com/yourusername/my-website.git

# Push your code to GitHub
git push -u origin main

Replace the URL with your actual GitHub repository URL. After running these commands, refresh your GitHub repository page — your project files should now appear there.

Never commit your .env.local file to GitHub. It contains sensitive credentials like API keys and database passwords. The .gitignore file created by create-next-app excludes it automatically — but always double-check before pushing. If you accidentally expose a secret key, revoke and regenerate it immediately.

Step 5: Deploy on Vercel

With your code on GitHub, deploying to Vercel takes under two minutes. The platform detects Next.js automatically and configures the build and deployment settings without any input from you.

Connect GitHub to Vercel and deploy

  1. Go to vercel.com and click Sign Up.
  2. Choose Continue with GitHub and authorize Vercel to access your GitHub account.
  3. On the Vercel dashboard, click Add New⬦ —  Project.
  4. You'll see a list of your GitHub repositories. Find my-website and click Import.
  5. Vercel automatically detects that it is a Next.js project and pre-fills all the build settings correctly:
    • Framework Preset: Next.js
    • Build Command: next build or npm run build
    • Output Directory: .next
    • Install Command: npm install
  6. Leave all settings at their defaults for now. Click Deploy.
  7. Vercel runs the build process. You can watch the build logs in real time. The first deployment typically takes 30—90 seconds.
  8. When deployment completes, Vercel shows a success screen with a confetti animation and your live URL.

Your URL will look like: https://my-website-yourusername.vercel.app. Click it — your website is live on the internet.

Vercel automatically assigns three URLs to every deployment: a unique deployment URL (for that specific build), a branch URL (always points to the latest build of a branch), and a production URL (your main .vercel.app domain). Share the production URL — it always reflects the latest deployment.

Step 6: Set Up Environment Variables

Most real-world Next.js applications use environment variables to store sensitive configuration — API keys, database connection strings, authentication secrets, and third-party service credentials. You define these in a .env.local file when developing locally, but for your Vercel deployment you add them through the dashboard, where they are stored securely and injected into your build and runtime environment.

Add environment variables in Vercel

  1. Open your project on the Vercel dashboard.
  2. Click the Settings tab.
  3. Click Environment Variables in the left sidebar.
  4. Click Add New and enter:
    • Key: the variable name (e.g. DATABASE_URL)
    • Value: the actual secret value
    • Environment: choose Production, Preview, or Development (or all three)
  5. Click Save. Repeat for each variable you need.
  6. After adding variables, redeploy your project for them to take effect — go to Deployments and click Redeploy on the latest deployment.

Using environment variables in your Next.js code

Access variables in your server-side code (API routes, Server Components, getServerSideProps) using process.env:

// In an API route or Server Component
const dbUrl = process.env.DATABASE_URL;
const apiKey = process.env.OPENAI_API_KEY;

To expose a variable to the browser (client-side code), prefix its name with NEXT_PUBLIC_:

# .env.local
NEXT_PUBLIC_GOOGLE_MAPS_KEY=your-maps-api-key-here

// In client-side code
const mapsKey = process.env.NEXT_PUBLIC_GOOGLE_MAPS_KEY;
Only use the NEXT_PUBLIC_ prefix for variables that are safe to expose to the browser. Standard environment variables (without this prefix) are server-only and are never included in the JavaScript bundle sent to users. Never prefix database passwords, secret keys, or private API credentials with NEXT_PUBLIC_.

Step 7: Automatic Updates with Git Push

One of Vercel's most powerful features is its automatic CI/CD pipeline. Every time you push code to your GitHub repository's main branch, Vercel automatically runs a new build and deploys the updated version. No manual steps required — your live site updates within about a minute of your push.

The standard update workflow

Edit your code in your text editor, then run these commands to push and trigger a deployment:

# Stage all changed files
git add .

# Commit with a descriptive message
git commit -m "Add contact page and update homepage hero"

# Push to GitHub (triggers Vercel deployment automatically)
git push

After pushing, open your Vercel dashboard — you will see a new deployment appear immediately in the Deployments list, changing from Building to Ready within a minute or two. The live production URL automatically points to the new version as soon as the build succeeds.

Write meaningful commit messages. Instead of "update" or "fix," write "Fix mobile navigation menu overflow on small screens" or "Add dark mode toggle to header." Good commit messages make it easy to identify what changed in each deployment — and to roll back if a deployment breaks something.

Rolling back a bad deployment

If a deployment introduces a bug or breaks your site, Vercel makes it easy to instantly roll back to a previous working version. In your Vercel dashboard, go to the Deployments tab, find the last working deployment, click the three-dot menu next to it, and select Promote to Production. Your site reverts to that version in seconds — no code changes required.

Step 8: Add a Custom Domain

The default .vercel.app URL works perfectly for development and portfolio projects, but for a professional website you will want a custom domain like yourname.com or yourstartup.co.ke. Vercel supports custom domains on the free Hobby plan, and the setup process is straightforward.

Connect your domain to Vercel

  1. Purchase a domain from a registrar — popular options include Namecheap, GoDaddy, Google Domains (now Squarespace Domains), or for Kenyan domains (.co.ke), use Kenya Network Information Centre (KeNIC) accredited registrars like Truehost or Safaricom Domains.
  2. In your Vercel project dashboard, go to Settings —  Domains.
  3. Type your domain name (e.g. mywebsite.com) and click Add.
  4. Vercel shows you DNS records to add at your domain registrar. You'll typically need to add either:
    • An A record pointing to Vercel's IP address (76.76.19.19) for apex domains like mywebsite.com
    • A CNAME record pointing to cname.vercel-dns.com for subdomains like www.mywebsite.com
  5. Log in to your domain registrar and add these DNS records in the DNS management panel.
  6. DNS propagation typically takes 5—30 minutes, occasionally up to 48 hours. Once it propagates, Vercel automatically provisions an SSL certificate for your domain.
Set up both mywebsite.com (apex domain) and www.mywebsite.com in Vercel, then configure one to redirect to the other. This ensures visitors who type either version reach the same site. Vercel handles the redirect automatically once both domains are added.

Step 9: Preview Deployments and Branching

One of the features that makes Vercel exceptional for professional development workflows is preview deployments. Every time you push to any branch other than main, Vercel automatically builds and deploys that branch to a unique temporary URL. This lets you test changes in a real production environment before merging them into your main site — without affecting what visitors see on your live production URL.

Working with preview deployments

Create a new branch for a feature you are building:

# Create and switch to a new branch
git checkout -b feature/new-homepage

# Make your changes, then push
git add .
git commit -m "Redesign homepage hero section"
git push -u origin feature/new-homepage

Vercel automatically builds this branch and gives it a URL like https://my-website-git-feature-newhomepage-yourusername.vercel.app. Share this URL with a colleague, client, or tester — they can review the live feature without seeing your production site.

When you are happy with the changes, merge the branch into main on GitHub. Vercel automatically promotes the new build to production.

Navigating the Vercel Dashboard

The Vercel dashboard is your control center for all deployed projects. Understanding its key sections helps you monitor, configure, and troubleshoot your deployments efficiently.

Deployments tab

Shows every deployment in reverse chronological order with status (Ready, Building, Error), the commit message that triggered it, the branch, and the deployment URL. Click any deployment to view full build logs — key for diagnosing build failures.

Analytics tab

Shows visitor data including page views, unique visitors, top pages, and traffic sources. The free plan includes basic analytics. Vercel Web Analytics can be enabled in your Next.js app with a few lines of code for more detailed real-user metrics.

Speed Insights tab

Shows Core Web Vitals (LCP, CLS, FID/INP) measured from real user visits. These metrics directly affect your site's Google search ranking. Vercel's Speed Insights helps you identify and fix performance issues on specific pages.

Logs tab

Shows real-time runtime logs from serverless functions and API routes. If your API routes are returning errors, this is the first place to look — you can filter by log level (error, warning, info) and by function name.

Settings —  Functions

Configure serverless function settings including region (choose the region closest to your users or database), memory allocation, and maximum execution duration. The free plan supports functions up to 10 seconds of execution time.

Settings —  Git

Configure which branches trigger production deployments, set up ignored build steps, and manage the GitHub integration. You can also connect Vercel to GitLab or Bitbucket repositories here.

Optimizing Your Next.js App for Production

Getting your site live is the first milestone. Making it fast and production-ready is the next. Next.js and Vercel together offer powerful optimization tools — here are the most impactful ones to implement before sharing your site with the world.

Image Optimization

Use Next.js's built-in Image component instead of regular HTML <img> tags. It automatically optimizes images — resizing, converting to modern formats (WebP, AVIF), and lazy-loading them. On Vercel, image optimization runs serverlessly with no configuration required.

import Image from 'next/image';

export default function Hero() {
  return (
    <Image
      src="/hero-photo.jpg"
      alt="Hero image"
      width={1200}
      height={630}
      priority   // load above-the-fold images eagerly
    />
  );
}

Metadata and SEO

Next.js App Router provides a structured way to define page metadata for SEO. Add a metadata export to any page:

// app/page.tsx
export const metadata = {
  title: 'My Website — Home',
  description: 'Welcome to my personal portfolio and blog.',
  openGraph: {
    title: 'My Website',
    description: 'Personal portfolio built with Next.js and deployed on Vercel',
    url: 'https://mywebsite.com',
    images: [{ url: '/og-image.png', width: 1200, height: 630 }],
  },
};

Static vs Server Rendering

Next.js App Router defaults to static rendering (pre-built at deploy time) for maximum performance. Pages that need real-time data use dynamic rendering. Choose the right approach for each page: use static rendering for pages whose content does not change frequently (home page, about page, blog posts), and server rendering or client-side data fetching for pages showing live data (dashboards, user profiles).

Understanding Vercel's Free Tier Limits

Vercel's Hobby (free) plan is genuinely generous for personal projects, portfolios, and small applications. However, it does have limits that you should be aware of so you are not surprised if your project exceeds them.

Feature Hobby (Free) Pro ($20/month per user)
Projects Unlimited personal projects Unlimited
Bandwidth 100 GB / month 1 TB / month
Serverless Function Duration 10 seconds max 300 seconds max
Build Minutes 6,000 minutes / month 24,000 minutes / month
Deployments per day 100 6,000
Team Members 1 (personal only — no teams) Up to 10 included
Custom Domains Unlimited Unlimited
Preview Deployments Yes Yes
Commercial Use Not permitted Permitted
The Hobby plan is for non-commercial personal projects only. If you are building a website for a business, a client, or generating revenue, Vercel's Terms of Service require you to use the Pro plan. Violating this can result in your account being suspended.

Alternatives to Vercel

Vercel is the best choice for most Next.js projects, but it is not the only option. Here is how it compares to the main alternatives.

Platform Best For Next.js Support Free Tier
Vercel Next.js (built by the same team) Native, all features Generous — 100GB bandwidth
Netlify Static sites, JAMstack Good — SSR via Netlify Functions 100GB bandwidth, 300 build minutes
Render Full-stack apps, APIs, databases Good — Node.js web service Free tier (cold starts on free plan)
Railway Full-stack with databases Good — containerized deployment $5/month free credits
GitHub Pages Purely static sites only Partial — static export only Free, no bandwidth limits
AWS / GCP / Azure Enterprise, complex infrastructure Manual configuration required Complex free tiers

Troubleshooting Common Problems

Build failed — "Module not found"

A package used in your code is not installed. Run npm install locally, then push again. Also check that the package is listed in package.json under dependencies (not just devDependencies if it is needed at runtime).

Build failed — TypeScript / ESLint errors

Next.js treats TypeScript type errors and ESLint errors as build failures by default. Fix the errors in your code, or temporarily add typescript: { ignoreBuildErrors: true } and eslint: { ignoreDuringBuilds: true } in next.config.js to unblock the deployment while you fix them.

Environment variables not working in production

Variables added to Vercel require a new deployment to take effect. After adding or changing variables in the dashboard, go to Deployments and click Redeploy. Also confirm that client-side variables use the NEXT_PUBLIC_ prefix.

Website showing old version after push

Check the Vercel dashboard — if the latest deployment shows a build error, the production URL stays on the last successful deployment. Fix the error in your code, push again, and the new deployment will promote to production automatically when it succeeds.

Custom domain showing "Invalid Configuration"

DNS records have not propagated yet or were entered incorrectly. Double-check the A record and CNAME values in your registrar's DNS panel against what Vercel shows in Settings —  Domains. Use a tool like dnschecker.org to verify propagation.

API routes returning 500 errors in production

Check the Logs tab in your Vercel dashboard and filter by Error level. The most common causes are missing environment variables, database connection errors (wrong credentials or IP allowlist), and unhandled promise rejections. Add proper try/catch error handling to your API routes.

404 error on page routes after deploy

If you are using the Pages Router (not App Router), check that your page files are in the pages/ directory. For App Router, each route needs a page.tsx or page.js file inside its folder. Also check that dynamic routes use the correct [param] folder naming.

Slow cold starts on serverless functions

The first request to a serverless function after a period of inactivity triggers a cold start (typically 200—500ms extra latency). Optimize function startup time by reducing imports, avoiding heavy initialization at module level, and considering Vercel's Edge Functions for latency-sensitive endpoints.

Frequently Asked Questions

Do I need to know React to use Next.js?

Next.js is built on top of React, so a basic understanding of React components, props, and state is very helpful. However, for simple websites (a portfolio, a blog, a landing page), you can get a long way with just HTML, CSS, and basic JavaScript inside Next.js's file-based routing system. If you are completely new to React, completing a React tutorial first (the official React docs at react.dev are excellent) will make your Next.js experience much smoother.

Is Vercel truly free? Will I be billed unexpectedly?

Vercel's Hobby plan is free and does not require a credit card to sign up. You'll not be billed unless you explicitly upgrade to a paid plan. However, the Hobby plan has usage limits (100GB bandwidth, 6,000 build minutes per month) — if you exceed these, Vercel will restrict your deployments rather than charge you. For the vast majority of personal projects, portfolios, and student projects, these limits are never approached.

Can I deploy a Next.js app with a database on Vercel?

Yes — and it works very well. Vercel has native integrations with several databases including Vercel Postgres (powered by Neon), Vercel KV (Redis), Vercel Blob (file storage), PlanetScale, Supabase, and MongoDB Atlas. You can also connect to any external database by adding the connection string as an environment variable. For serverless deployments, use a database that supports connection pooling (like Neon or PlanetScale) to avoid exhausting connection limits.

What happens if my Next.js site gets a lot of traffic?

Vercel's infrastructure auto-scales. Your site will not go down from a traffic spike — Vercel spins up additional serverless function instances automatically. On the Hobby plan, the 100GB monthly bandwidth limit is the primary constraint. If you genuinely expect high traffic, upgrading to the Pro plan gives you 1TB of bandwidth and removes the commercial use restriction.

Can I deploy a Next.js app to Vercel without using GitHub?

Yes — Vercel also supports GitLab and Bitbucket repositories. You can also deploy directly from the command line using the Vercel CLI: install it with npm install -g vercel, then run vercel inside your project folder and follow the prompts. This is useful for quick deployments without setting up a Git repository, though the Git-based workflow is recommended for production projects because it gives you automatic deployments and a full deployment history.

 Conclusion

Deploying a Next.js website on Vercel is one of the smoothest experiences in modern web development. What used to require server configuration, SSL certificate management, and complex CI/CD pipelines now happens automatically in under two minutes — for free. From the moment you push your code to GitHub, Vercel handles the build, deployment, CDN distribution, HTTPS, and automatic updates without any intervention from you.

As your project grows, Vercel grows with it. Start with the free Hobby plan for your portfolio, personal projects, or learning experiments. Add a custom domain, set up environment variables, explore preview deployments for testing features, and use the built-in analytics to understand your visitors. When your project becomes a business, the upgrade path to Vercel Pro is smooth.

The best time to deploy your Next.js project is right now — before it is "finished," before it is perfect, before every feature is built. Get it live, share the URL, and iterate from there. That's how modern web development works, and Vercel makes it easier than it has ever been.