Setting Up Serverless Deployment Workflow with GitHub, Vercel, and Netlify
Setting Up Serverless Deployment Workflow with GitHub, Vercel, and Netlify
You've built something. Maybe it's a landing page, a documentation site, or a full Next.js application. Now you need it live—preferably without wrestling with servers, SSH keys, or deployment scripts that break at 2 AM.
This is where a serverless deployment workflow changes everything. Connect your Git repository to a platform like Vercel or Netlify, push your code, and watch it go live automatically. No infrastructure management. No manual uploads. Just code → commit → deploy.
This guide walks you through the complete setup for static site deployment with GitHub, Vercel, and Netlify—including when to choose each platform and how to avoid the gotchas that slow down first-time setups.
The Core Loop: How Git-Based Deployment Works
Before diving into platform specifics, understand the fundamental pattern:
- You push code to GitHub (or merge a pull request)
- The platform detects the change via webhook
- A build process runs (npm run build, Hugo, Jekyll, etc.)
- Output gets deployed to a global CDN
- Your site is live—usually within 30-90 seconds
Both Vercel and Netlify handle this natively. GitHub serves as your source of truth and can optionally run custom CI via Actions. The magic is in the integration—once connected, you rarely think about deployment again.
Choosing Your Platform: Decision Framework
Both Vercel and Netlify are excellent. The "right" choice depends on your specific stack and needs. Here's how to decide:
Choose Vercel If:
- You're using Next.js (Vercel maintains it—first-class support is unmatched)
- You need Edge Functions for geolocation, A/B testing at the edge, or middleware
- You want zero-config deployment—Vercel auto-detects frameworks and configures builds
- Performance analytics matter (built-in Core Web Vitals tracking)
- You're building a SaaS landing page or app that benefits from ISR (Incremental Static Regeneration)
Choose Netlify If:
- You need built-in form handling without setting up a backend
- You want identity/authentication features out of the box
- Your workflow benefits from plugins (image optimization, CMS integration, etc.)
- Split testing is important for conversion optimization
- You're framework-agnostic and want maximum flexibility
Use GitHub Actions Alongside Either If:
- You need custom CI steps before deployment (complex test suites, linting, security scans)
- You're deploying to multiple environments with different logic
- You want full control over the build pipeline
Step-by-Step: Deploy a Static Site with GitHub and Vercel
Let's walk through the most common setup—a Next.js or static site deploying via Vercel.
1. Prepare Your GitHub Repository
Ensure your project lives in a GitHub repository. If you're starting fresh:
- Initialize your project locally
- Create a new repo on GitHub (public or private—both work)
- Push your code to the main branch
Your repo should include a valid package.json with build scripts, or be a recognized static site generator (Hugo, Jekyll, Gatsby, etc.).
2. Connect GitHub to Vercel
- Go to Vercel and sign in with your GitHub account
- Click "Add New Project"
- Select the repository you want to deploy
- Vercel auto-detects your framework (Next.js, Create React App, Hugo, etc.)
3. Configure Build Settings
For most projects, Vercel's defaults work immediately. If you need customization:
- Build Command: Usually
npm run buildoryarn build - Output Directory:
outfor Next.js static export,buildfor CRA,publicfor Hugo - Environment Variables: Add any API keys or config values here
4. Deploy and Test
Click "Deploy." Within a minute, your site is live with:
- A unique
.vercel.appURL - Automatic HTTPS
- Global CDN distribution
Every subsequent push to your main branch triggers a new production deployment. Every pull request gets a unique preview URL—perfect for reviewing changes before merging.
Step-by-Step: Deploy with GitHub and Netlify
The Netlify workflow is similarly straightforward but offers different configuration options.
1. Connect Your Repository
- Log into Netlify and click "Add new site" → "Import an existing project"
- Authorize GitHub access and select your repository
- Choose the branch to deploy (typically
mainormaster)
2. Configure Build Settings
Netlify also auto-detects common frameworks. Manual configuration options include:
- Base directory: Leave blank unless your project is in a subdirectory
- Build command:
npm run build,hugo,jekyll build, etc. - Publish directory: Where your static files land after build (
dist,build,public)
3. Optional: Configure netlify.toml
For version-controlled configuration, add a netlify.toml file to your repo root:
[build]
command = "npm run build"
publish = "dist"
This ensures consistent builds across team members and prevents dashboard drift.
4. Enable Additional Features
Where Netlify shines—activate these from the dashboard:
- Forms: Add
netlifyattribute to any form and submissions are captured automatically - Identity: Enable user authentication without a backend
- Plugins: Browse and install from the extensive plugin marketplace
- Split Testing: Run A/B tests on different branches
Advanced: Using GitHub Actions for Custom CI/CD
Sometimes you need more control than the built-in CI provides. Maybe you want to run extensive tests, generate assets, or deploy conditionally. This is where GitHub Actions comes in.
Setting Up Netlify with GitHub Actions for Static Sites
Create .github/workflows/deploy.yml in your repository:
name: Deploy to Netlify
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
- run: npm ci
- run: npm test
- run: npm run build
- name: Deploy to Netlify
uses: netlify/actions/cli@master
with:
args: deploy --prod --dir=dist
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
Store your Netlify auth token and site ID in GitHub Secrets. This approach gives you full control over the build pipeline while still leveraging Netlify's CDN and features.
Platform Comparison: Vercel vs Netlify for JAMstack Deployment
Here's how the platforms stack up across key criteria:
Build & Deployment
- Git-push deploy: Both native and automatic
- Preview URLs: Both generate unique URLs per pull request
- Build detection: Vercel slightly better at framework auto-detection; Netlify more configurable
Framework Support
- Vercel: Next.js first-class (ISR, Edge Middleware, App Router optimizations)
- Netlify: Framework-agnostic with excellent Hugo, Gatsby, and 11ty support
Serverless Functions
- Vercel: Edge Functions (run closer to users, lower latency)
- Netlify: AWS Lambda-based Functions (more mature, broader compatibility)
Free Tier Limits
- Vercel: 100 GB bandwidth, 1M serverless function invocations/month
- Netlify: 100 GB bandwidth, 125k function invocations/month
- GitHub Actions: 2,000 minutes/month for private repos (unlimited for public)
Unique Features
- Vercel: Performance analytics, Edge Config, faster cold starts
- Netlify: Forms, Identity, split testing, extensive plugin ecosystem
Real-World Stack Examples
Marketing Microsite (Lead Generation)
Stack: GitHub → Netlify → Netlify Forms + Image Optimization Plugin
Why it works: Built-in form handling captures leads without any backend. A/B test different CTAs using split testing. Image plugin optimizes assets automatically.
SaaS Landing Page + Documentation
Stack: GitHub → Vercel → Next.js with Edge Functions
Why it works: Next.js App Router for fast page loads. Edge Functions handle geolocation-based pricing display. ISR keeps docs fresh without full rebuilds.
Personal Blog (Hugo or 11ty)
Stack: GitHub → Netlify → Netlify CMS
Why it works: Static site generators build lightning-fast pages. Netlify CMS provides a git-based content editor. Zero hosting costs on free tier.
Frequently Asked Questions
How do I deploy a static site with GitHub and Vercel?
Connect your GitHub repo to Vercel, select your framework or specify your build command, set the output folder (e.g., "out" for Next.js static export), then push to your main branch. Every push triggers an automatic build and deploy—your site goes live within seconds.
What's the difference between Vercel and Netlify?
Both offer Git-triggered builds, global CDNs, preview URLs, and serverless functions. Vercel is optimized for Next.js with Edge Functions and ISR support. Netlify has a more mature plugin ecosystem, built-in form handling, identity management, and split testing capabilities.
Can I use GitHub Actions instead of Vercel/Netlify's built-in CI?
Yes. Configure a GitHub Actions workflow to run your build command (npm run build), then use the Vercel CLI or Netlify CLI to publish. This gives you more control over the build process—useful for complex test suites or conditional deployments—but adds configuration complexity.
Which platform is cheaper at scale?
Both have similar free tiers. At scale, Vercel Pro runs $20/user/month (1 TB bandwidth, 5M invocations), while Netlify Pro is $19/user/month (400 GB bandwidth, 1M invocations). Vercel typically offers better value for high-traffic sites; Netlify may cost less for sites with many serverless function calls but lower bandwidth needs.
Common Pitfalls and How to Avoid Them
- Build command mismatch: Ensure your package.json
buildscript matches what the platform expects. Test locally first.