▲ Deploy Next.js on Cloudflare with GitHub Actions

Deployment blueprint • 2026 • ⚙️ GitHub Actions

Advertisement Space - Google AdSense

Key Features

⚡ Zero egress fees - unlimited bandwidth
🌍 Global CDN with 300+ edge locations
🔒 Automatic HTTPS with SSL certificates
🔄 Automatic preview deployments for PRs
💰 Free tier: 500 builds/month, unlimited requests
⚠️ Static export only - no SSR or API routes

📋 Configuration Files

Copy these files into your project:

.github/workflows/deploy.yml
# .github/workflows/deploy.yml
name: Deploy Next.js to Cloudflare Pages

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  deploy:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      deployments: write
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'

      - name: Install dependencies
        run: npm ci

      - name: Build Next.js (Static Export)
        run: npm run build
        env:
          NODE_ENV: production

      - name: Deploy to Cloudflare Pages
        uses: cloudflare/pages-action@v1
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
          projectName: my-nextjs-app
          directory: out
          gitHubToken: ${{ secrets.GITHUB_TOKEN }}

# next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
  output: 'export',
  images: {
    unoptimized: true,
  },
  trailingSlash: true,
}

module.exports = nextConfig

📦 Need all the files?

Download the complete blueprint with README, package.json, and all configuration files.

📥 Browse All Files

Configuration Summary

🚀
Framework
Next.js
☁️
Cloud Provider
Cloudflare Pages & Workers
⚙️
Deployment Tool
GitHub Actions
💰
Pricing
Free tier generous, zero egress fees, flat-rate pricing

☁️ About Cloudflare Pages & Workers

Edge-first platform with zero egress fees

✓ Best For
Static sites, edge computing, cost-effective CDN, global performance
💰 Pricing
Free tier generous, zero egress fees, flat-rate pricing

Available Services:

Pages - Static Site Hosting
Workers - Edge Computing
R2 - Object Storage (S3-compatible)
D1 - SQLite Database
KV - Key-Value Storage
Durable Objects - Stateful Edge
Stream - Video Streaming
Images - Image Optimization
CDN - Global Network
DNS - Managed DNS

✅ Prerequisites

Make sure you have these ready before starting:

Node.js 18+ installed
GitHub account with repository admin access
Cloudflare account (free tier works)
Git installed locally
Basic knowledge of Next.js and React

🚀 Step-by-Step Implementation

Follow these steps to deploy your Next.js application:

  1. 1
    Initialize Next.js: npx create-next-app@latest my-nextjs-app
  2. 2
    Update next.config.js to enable static export (output: "export")
  3. 3
    Set images.unoptimized: true for static export
  4. 4
    Create GitHub repository and push code
  5. 5
    In Cloudflare Dashboard, create new Pages project
  6. 6
    Get Account ID from Pages dashboard
  7. 7
    Create API Token with "Cloudflare Pages:Edit" permissions
  8. 8
    Add CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID to GitHub Secrets
  9. 9
    Create .github/workflows/deploy.yml
  10. 10
    Update projectName in workflow
  11. 11
    Push to main branch to deploy
  12. 12
    Access site at https://my-nextjs-app.pages.dev

💡 Additional Notes & Tips

📚 About This Stack

▲ Next.js

React framework with server-side rendering and static generation

🟠 Cloudflare

Edge-first platform with zero egress fees

⚙️ GitHub Actions

CI/CD automation directly in GitHub

🏷️ Tags & Keywords

Next.js Cloudflare Cloudflare Pages & Workers GitHub Actions CI/CD DevOps Infrastructure as Code Next.js Deployment Cloudflare Hosting Production Ready 2026

Advertisement Space - Google AdSense