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 FilesConfiguration 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:
- 1Initialize Next.js: npx create-next-app@latest my-nextjs-app
- 2Update next.config.js to enable static export (output: "export")
- 3Set images.unoptimized: true for static export
- 4Create GitHub repository and push code
- 5In Cloudflare Dashboard, create new Pages project
- 6Get Account ID from Pages dashboard
- 7Create API Token with "Cloudflare Pages:Edit" permissions
- 8Add CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID to GitHub Secrets
- 9Create .github/workflows/deploy.yml
- 10Update projectName in workflow
- 11Push to main branch to deploy
- 12Access site at https://my-nextjs-app.pages.dev
💡 Additional Notes & Tips
- 📦 For SSR, use @cloudflare/next-on-pages
- 🖼️ Image optimization disabled for static export
📚 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 2026Advertisement Space - Google AdSense