Logo van Cloudflare Pages

Cloudflare Pages

Community
Omar-Obando
cloudflare-pages

Use when deploying applications to Cloudflare Pages, configuring edge functions, caching strategies, and optimizing performance on Cloudflare's global network. Includes Wrangler CLI, edge computing, and global distribution. Based on Cloudflare Certified Developer and edge computing best practices.

Add to TypingMind

Overzicht

UitgeverOmar-Obando
Repositoryqwen-orchestrator
Skillnaamcloudflare-pages
Sterren
53
Forks
13
Meegeleverde bestanden
Alleen instructies
LicentieMIT
Links
  • Instructies in Markdown

    Het model laadt het bestand SKILL.md alleen als dat nodig is. Dat kost dus alleen tokens als een verzoek daadwerkelijk bij de skill past.

  • Werkt met elk LLM

    AI-skills bestaan uit instructies in gewone Markdown, niet uit aanbiederspecifieke code. Daardoor werken ze met GPT, Claude, Gemini, Grok of een lokaal model.

  • Compleet zonder extra bestanden

    Alles wat het model nodig heeft, staat in de instructies — geen extra bestanden om te synchroniseren.

  • Open source

    Gepubliceerd door Omar-Obando op GitHub. Bekijk de bronbestanden voordat je de skill installeert.

Installatie

Installeer de AI-skill Cloudflare Pages in TypingMind om deze met elk LLM te gebruiken, of voeg de skill toe aan een andere agent die SKILL.md kan lezen.

1

Installeren in TypingMind

TypingMind installeert een skill rechtstreeks vanuit de GitHub-map. De app leest SKILL.md, bundelt de bijbehorende bestanden en slaat het resultaat lokaal op.

  1. Open de app en ga naar Plug-ins → Skills.
  2. Kies "Installeren via GitHub".
  3. Plak de onderstaande URL van de skillmap en bevestig.
    https://github.com/Omar-Obando/qwen-orchestrator/tree/main/skills/cloudflare-pages
  4. Schakel de skill in voor elke chat waarin je de skill wilt kunnen gebruiken.
Plug-ins → Skills → Skill toevoegen → Via GitHub-URL. Plak vervolgens de map-URL en druk op Doorgaan.
2

Installeren in een andere agent

Elke agent die het Agent Skills-formaat kan lezen, kan deze skill gebruiken — kopieer de map naar de skillmap van die agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Omar-Obando/qwen-orchestrator.git /tmp/qwen-orchestrator
mkdir -p .claude/skills
cp -r /tmp/qwen-orchestrator/skills/cloudflare-pages .claude/skills/cloudflare-pages
Start Claude Code na het kopiëren opnieuw op, zodat de nieuwe skill wordt herkend.

Gebruik deze skill in TypingMind

Schakel Cloudflare Pages in voor een chat naar keuze in TypingMind en het model doet de rest. De naam en beschrijving staan in de systeemprompt. Zodra een verzoek bij de skill past, laadt het model zelf de volledige instructies. Je hoeft de skill nooit handmatig aan te roepen. Pas als het model de skill daadwerkelijk gebruikt, kost dat tokens.

Het model laadt Cloudflare Pages automatisch zodra een verzoek erbij past.

Werkt met elk AI-model

AI-skills zijn gewone Markdown-instructies in plaats van aanbiederspecifieke code. Daardoor is Cloudflare Pages niet gebonden aan het model waarvoor de skill is geschreven. Installeer de skill één keer in TypingMind en gebruik deze met GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama of een lokaal model dat je zelf draait — allemaal met je eigen API-sleutels.

  • Alleen geladen wanneer nodig

    De systeemprompt bevat alleen de naam en beschrijving. De instructies worden bij het eerste bijpassende verzoek opgehaald, dus een ongebruikte skill kost niets.

  • Wissel van model tijdens een chat

    Omdat de skill uit instructies bestaat en niet uit code, blijft deze werken als je van model wisselt — het volgende model leest hetzelfde SKILL.md-bestand.

Skillinstructies

Dit is de inhoud van SKILL.md die het model laadt. Lees deze vóór de installatie — een skill bestaat uit instructies die je model zal volgen.

Cloudflare Pages Skill — Edge Computing & Global Deployment

Overview

This skill provides comprehensive guidance for deploying applications to Cloudflare Pages, configuring edge functions, caching strategies, and optimizing performance on Cloudflare's global network. It includes Wrangler CLI, edge computing, and global distribution. Based on Cloudflare Certified Developer and edge computing best practices.

When to Use

Use this skill when:

  • Deploying applications to Cloudflare Pages
  • Configuring edge functions and middleware for Pages
  • Setting up global distribution with Cloudflare's edge network
  • Optimizing caching and performance at the edge
  • Using Wrangler CLI for local development and deployment
  • Configuring environment variables and secrets for Pages
  • Setting up preview deployments for pull requests
  • Configuring custom domains and SSL certificates
  • Implementing edge routing and redirects
  • Using Cloudflare Analytics and monitoring
  • Deploying with Git integration (GitHub, GitLab, Bitbucket)
  • Setting up automatic deployments on push
  • Configuring build environment variables
  • Using Cloudflare KV storage for edge data
  • Implementing A/B testing and feature flags at edge
  • Setting up Cloudflare Images optimization
  • Using Cloudflare AI for edge processing

Do NOT use this skill when:

  • Writing application business logic (use developer skill or specific framework skill)
  • Designing database schema (use database-design skill)
  • Creating UI components (use frontend-design skill)
  • Managing non-Cloudflare infrastructure (use aws-serverless, azure-cloud, or gcp-cloud skills)
  • Performing security audits (use security-auditor skill)
  • Setting up Kubernetes deployments (use devops-pipeline skill)
  • Developing Cloudflare Workers (use cloudflare-workers skill - different from Pages)
  • Deploying to Vercel (use vercel-deployment skill)

Why avoid: Cloudflare Pages is for static sites and edge functions. For full Workers development or other platforms, use targeted skills.

Deployment Methods

Git Integration

yaml
# .github/workflows/deploy.yml
name: Deploy to Cloudflare Pages
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: cloudflare/pages-action@v1
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
          projectName: my-app
          directory: ./dist
          buildCommand: npm run build

Direct Upload

bash
# Deploy with Wrangler
npx wrangler pages deploy ./dist --project-name=my-app

# Deploy with preview
npx wrangler pages deploy ./dist --project-name=my-app --branch=preview

C3 CLI

bash
# Create new project
npx create-cloudflare@latest

# Deploy project
npx wrangler pages deploy ./dist

Edge Functions

Basic Edge Function

typescript
// functions/[...].ts
export async function onRequest(context) {
  const { request, env, execution } = context;

  // Modify request
  const url = new URL(request.url);

  // Add custom headers
  const response = await fetch(request);
  response.headers.set('X-Custom-Header', 'value');

  return response;
}

Middleware

typescript
// middleware.ts
export async function onRequest(context, next) {
  const { request, env } = context;

  // Authentication check
  const token = request.headers.get('Authorization');
  if (!token && request.url.includes('/api')) {
    return new Response('Unauthorized', { status: 401 });
  }

  // Continue to next handler
  return next();
}

Routing

typescript
// functions/api/users.ts
export async function onRequest(context) {
  const { request, env } = context;

  switch (request.method) {
    case 'GET':
      return getUsers(request, env);
    case 'POST':
      return createUser(request, env);
    default:
      return new Response('Method Not Allowed', { status: 405 });
  }
}

async function getUsers(request, env) {
  // Get users from database
  const users = await env.DB.prepare('SELECT * FROM users').all();
  return new Response(JSON.stringify(users), {
    headers: { 'Content-Type': 'application/json' },
  });
}

Caching Strategies

Cache Control Headers

typescript
// Cache static assets
export async function onRequest(context) {
  const response = await fetch(context.request);

  // Cache for 1 year (immutable)
  response.headers.set('Cache-Control', 'public, max-age=31536000, immutable');

  return response;
}

Edge Caching

typescript
// Cache API responses at edge
export async function onRequest(context) {
  const url = new URL(context.request.url);

  if (url.pathname === '/api/data') {
    // Cache for 1 hour
    const cacheControl = 'public, max-age=3600';

    // Try to serve from cache
    const cached = await caches.default.match(context.request);
    if (cached) {
      return cached;
    }

    // Fetch and cache
    const response = await fetch(context.request);
    response.headers.set('Cache-Control', cacheControl);

    context.waitUntil(caches.default.put(context.request, response.clone()));

    return response;
  }

  return fetch(context.request);
}

Wrangler CLI Commands

Development

bash
# Start local development
npx wrangler pages dev ./dist

# Start with environment variables
npx wrangler pages dev ./dist --env=development

# Start with custom port
npx wrangler pages dev ./dist --port=3000

Deployment

bash
# Deploy to production
npx wrangler pages deploy ./dist --project-name=my-app

# Deploy with preview
npx wrangler pages deploy ./dist --project-name=my-app --branch=preview

# Deploy with environment variables
npx wrangler pages deploy ./dist --project-name=my-app --env=production

Configuration

toml
# wrangler.toml
name = "my-app"
compatibility_date = "2024-01-01"

[[pages_functions]]
path = "functions"

[[routes]]
path = "/*"
handler = "functions/[...].ts"

Environment Variables

Project Settings

bash
# Set environment variable
npx wrangler pages environment set VARIABLE_NAME value

# Set production environment variable
npx wrangler pages environment set VARIABLE_NAME value --environment=production

# List environment variables
npx wrangler pages environment list

# Remove environment variable
npx wrangler pages environment delete VARIABLE_NAME

Cloudflare Dashboard

  1. Navigate to Pages project
  2. Go to "Settings" → "Environment Variables"
  3. Add variables for each environment
  4. Set "Production", "Preview", or "Build & Development" scope

Global Distribution

Region Configuration

typescript
// Edge function with region-specific logic
export async function onRequest(context) {
  const { cf } = context.request;

  // Get client country
  const country = cf.country;

  // Serve region-specific content
  if (country === 'US') {
    return new Response('US Content');
  } else if (country === 'EU') {
    return new Response('EU Content');
  }

  return new Response('Global Content');
}

Multi-Region Deployment

bash
# Deploy to specific regions
npx wrangler pages deploy ./dist \
  --project-name=my-app \
  --region=iad1 \
  --region=sfo1

Performance Optimization

Edge Caching

  • Static Assets: Cache for 1 year with immutable
  • API Responses: Cache for 1 hour with revalidation
  • Dynamic Content: No caching or short TTL

Image Optimization

typescript
// Image optimization at edge
export async function onRequest(context) {
  const url = new URL(context.request.url);

  if (url.pathname.startsWith('/images/')) {
    // Optimize image at edge
    const optimized = await optimizeImage(url.pathname);
    return new Response(optimized, {
      headers: {
        'Content-Type': 'image/webp',
        'Cache-Control': 'public, max-age=31536000, immutable',
      },
    });
  }

  return fetch(context.request);
}

Common Anti-Patterns

❌ Bad: No Edge Functions

typescript
// ❌ BAD: All logic in origin server
export async function onRequest(context) {
  // All processing happens at origin
  const data = await db.query('SELECT * FROM users');
  return new Response(JSON.stringify(data));
}

Problems:

  • High latency
  • Origin server load
  • No global distribution

✅ Good: Edge Processing

typescript
// ✅ GOOD: Edge processing
export async function onRequest(context) {
  // Cache at edge
  const cached = await caches.default.match(context.request);
  if (cached) {
    return cached;
  }

  // Fetch from origin
  const response = await fetch(context.request);

  // Cache at edge
  context.waitUntil(caches.default.put(context.request, response.clone()));

  return response;
}

❌ Bad: Large Edge Functions

typescript
// ❌ BAD: Large edge function with heavy dependencies
import { bigLibrary } from 'big-library';

export async function onRequest(context) {
  // Heavy initialization
  const result = bigLibrary.process(context.request);
  return new Response(JSON.stringify(result));
}

Problems:

  • Slow cold starts
  • High memory usage
  • Expensive execution

✅ Good: Optimized Edge Function

typescript
// ✅ GOOD: Optimized edge function
export async function onRequest(context) {
  // Lightweight processing
  const result = processRequest(context.request);
  return new Response(JSON.stringify(result));
}

function processRequest(request) {
  // Simple, focused logic
  return { processed: true };
}

Real-World Impact

Before this skill:

  • High latency
  • Origin server load
  • No global distribution
  • Poor caching

After this skill:

  • Low latency
  • Edge processing
  • Global distribution
  • Optimal caching

Cross-References

  • devops-pipeline - For CI/CD integration
  • architecture-patterns - For edge architecture design
  • testing-strategy - For testing edge functions

References

Veelgestelde vragen

Wat doet de AI-skill Cloudflare Pages?

Use when deploying applications to Cloudflare Pages, configuring edge functions, caching strategies, and optimizing performance on Cloudflare's global network. Includes Wrangler CLI, edge computing, and global distribution. Based on Cloudflare Certified Developer and edge computing best practices.

Waarom Cloudflare Pages gebruiken in TypingMind?

Omdat je deze skill één keer installeert en met elk model kunt gebruiken. Cloudflare Pages bestaat uit gewone Markdown in plaats van aanbiederspecifieke code. Dezelfde skill werkt dus met GPT-5, Claude, Gemini, Grok of een lokaal model. Ook als je midden in een chat van model wisselt, blijft de skill werken. TypingMind werkt met je eigen API-sleutels, dus je betaalt aanbieders rechtstreeks in plaats van een abonnement per gebruikersplek af te sluiten. Je skills en chats blijven in je eigen opslag.

Hoe installeer ik Cloudflare Pages in TypingMind?

Open Plug-ins → Skills → Installeren vanaf GitHub in TypingMind en plak https://github.com/Omar-Obando/qwen-orchestrator/tree/main/skills/cloudflare-pages. TypingMind leest het bestand SKILL.md en installeert het als een skill die je per chat kunt inschakelen.

Welke AI-modellen kunnen Cloudflare Pages gebruiken?

Elk model dat je in TypingMind koppelt. AI-skills bestaan uit gewone Markdown-instructies in plaats van aanbiederspecifieke code. GPT, Claude, Gemini, Grok en lokale modellen kunnen deze skill dus allemaal laden wanneer een verzoek erbij past.

Hoeveel AI-modellen kan ik met Cloudflare Pages gebruiken?

Zoveel als je wilt. Je kunt Cloudflare Pages gebruiken met elk model dat skills ondersteunt, zoals GPT, Claude, Gemini, Grok, DeepSeek, Mistral of Llama. Allemaal in TypingMind met je eigen API-sleutels.

Is de AI-skill Cloudflare Pages gratis?

Ja. Deze skill is door Omar-Obando op GitHub gepubliceerd onder de licentie MIT. Je betaalt alleen je eigen AI-aanbieder voor de tokens die je gebruikt.

Wat zijn AI-skills?

Een AI-skill is een herbruikbare bundel instructies die een AI-model leert hoe het één specifieke taak moet uitvoeren. De skill volgt het open Agent Skills-formaat: het bestand SKILL.md bevat de naam en beschrijving van de skill. Daarnaast kan de skill scripts, sjablonen of referentiebestanden bevatten die het model nodig heeft. Het model leest de instructies alleen als je verzoek bij de skill past. Een geïnstalleerde skill kost dus niets zolang deze niet wordt gebruikt.

Waarin verschillen AI-skills van plug-ins of MCP-servers?

Een plug-in of MCP-server geeft een model nieuwe tools om aan te roepen: code die ergens wordt uitgevoerd en een resultaat teruggeeft. Een AI-skill geeft het model juist kennis en een werkwijze: hoe het een taak moet aanpakken, welke stappen het moet volgen en hoe goede uitvoer eruitziet. Skills bestaan uit gewone Markdown en hebben dus geen server, API-sleutel of runtime nodig. Ze werken met elk model.

Bekijk alles

Maak nu je eigen AI-werkruimte

Schrijf je in voor onze nieuwsbrief en blijf op de hoogte van nieuwe functies en toekomstige weggeefacties 👇