Deploying to Cloudflare Workers

October 19, 2025 • Solar Team

Deploying to Cloudflare Workers

A step-by-step guide to deploying your Next.js static blog to Cloudflare Workers.

Prerequisites

  1. A Cloudflare account (free tier works!)
  2. Node.js 20+ installed
  3. Your Next.js blog built and ready

Step 1: Build Your Site

npm run build

This creates an out/ directory with all static files.

Step 2: Create wrangler.toml

Create a wrangler.toml file in your project root:

name = "solar-blog"
compatibility_date = "2025-01-01"
compatibility_flags = ["nodejs_compat"]

[assets]
directory = "./out"
binding = "ASSETS"

Step 3: Install Wrangler

npm install -g wrangler

Or use it via npx without global installation.

Step 4: Authenticate

wrangler login

This opens your browser to authenticate with Cloudflare.

Step 5: Deploy

wrangler deploy

Your blog will be deployed to a *.workers.dev subdomain!

Custom Domain

To use a custom domain:

  1. Add your domain to Cloudflare
  2. Update wrangler.toml:
routes = [
  { pattern = "blog.yourdomain.com", custom_domain = true }
]
  1. Deploy again

CI/CD with GitHub Actions

Automate deployments with GitHub Actions:

name: Deploy to Cloudflare Workers

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: '20'
      - run: npm ci
      - run: npm run build
      - uses: cloudflare/wrangler-action@v3
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}

Performance Benefits

Cloudflare Workers provides:

  • Global Edge Network - 300+ locations worldwide
  • Instant Cache Updates - No CDN purge delays
  • Free Tier - Generous limits for static sites
  • Automatic SSL - HTTPS enabled by default
  • DDoS Protection - Enterprise-grade security

Monitoring

View your site's analytics in the Cloudflare dashboard:

  • Request counts
  • Bandwidth usage
  • Error rates
  • Geographic distribution

Cost

For a typical blog:

  • Static asset requests: FREE
  • Worker invocations: Only if you add server logic
  • Bandwidth: Unlimited on all plans

Conclusion

Cloudflare Workers is an excellent choice for hosting static Next.js blogs. Fast, reliable, and cost-effective!