Cloudflare Pages - Full-stack JAMstack platform with global CDN, serverless functions, Git integration, and native bindings to Workers, KV, R2, D1, and Durable Objects
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Um comando direto ignora o prompt de revisão. Verifique a origem antes de executá-lo.
Instruções da origem · Visualização somente leitura
name
cloudflare-pages
version
1.0.0
description
Cloudflare Pages - Full-stack JAMstack platform with global CDN, serverless functions, Git integration, and native bindings to Workers, KV, R2, D1, and Durable Objects
Cloudflare Pages Skill
Cloudflare Pages is a JAMstack platform for deploying full-stack applications to Cloudflare's global network. It combines static site hosting with serverless Pages Functions, automatic Git deployments, and native integrations with the Cloudflare ecosystem (Workers, KV, R2, D1, Durable Objects).
Key Value Proposition: Deploy static sites and full-stack applications with zero configuration, automatic preview deployments, unlimited bandwidth, and seamless access to Cloudflare's edge computing and storage services.
When to Use This Skill
Deploying static sites or JAMstack applications
Building full-stack apps with serverless functions
Configuring Pages Functions with bindings (KV, R2, D1)
Setting up Git-based CI/CD with preview deployments
Configuring headers, redirects, and routing
Troubleshooting build or deployment issues
Migrating from other hosting platforms to Pages
When NOT to Use This Skill
For Cloudflare Workers alone (use workers skill)
For general Cloudflare CDN/DNS configuration
For non-web applications or APIs without UI
For container-based deployments (Pages is serverless)
# 1. Connect repository in Cloudflare Dashboard# Workers & Pages > Create application > Connect to Git# 2. Configure build settings# - Production branch: main# - Build command: npm run build# - Build output: dist# 3. Push to deploy
git push origin main
Deploy with Wrangler CLI
# Install Wrangler
npm install -g wrangler
# Login to Cloudflare
wrangler login
# Create a new project
npx wrangler pages project create my-site
# Deploy to production
npx wrangler pages deploy ./dist
# Deploy preview
npx wrangler pages deploy ./dist --branch=staging
Deploy via Dashboard
Go to Workers & Pages > Create application
Click Get started under Pages
Drag and drop your build folder or zip file
Enter project name and deploy
Build Configuration
Framework Presets
Cloudflare provides presets for 31+ frameworks:
Framework
Build Command
Output Directory
React (Vite)
npm run build
dist
Next.js
npx @cloudflare/next-on-pages@1
.vercel/output/static
Astro
npm run build
dist
SvelteKit
npm run build
.svelte-kit/cloudflare
Nuxt
npm run build
dist
Remix
npm run build
public
Vue (Vite)
npm run build
dist
Angular
npm run build
dist/<project>
Gatsby
gatsby build
public
Hugo
hugo
public
Docusaurus
npm run build
build
Eleventy
npx @11ty/eleventy
_site
System Environment Variables
These are automatically injected during builds:
Variable
Description
Example
CF_PAGES
Always 1 on Pages
1
CF_PAGES_COMMIT_SHA
Git commit hash
a1b2c3d...
CF_PAGES_BRANCH
Branch name
main
CF_PAGES_URL
Deployment URL
https://abc.pages.dev
CI
Always true
true
Custom Environment Variables
# Set via dashboard: Settings > Environment variables# Or in wrangler.toml
[vars]
API_URL = "https://api.example.com"# Secrets (encrypted)# Set via: wrangler pages secret put SECRET_NAME
Paths not matching either are served as static assets
Max 100 rules combined
Deployment Methods
Git Integration (Recommended)
GitHub Setup:
Workers & Pages > Create application > Connect to Git
Select GitHub and authorize
Choose repository
Configure build settings
Deploy
GitLab Setup:
Requires Maintainer role or higher
Grants access to all repositories on account
Branch Configuration:
Production branch: main (configurable)
Preview branches: All non-production (configurable)
Custom rules: Include/exclude patterns
Direct Upload (Wrangler)
# Create project
npx wrangler pages project create my-app
# List projects
npx wrangler pages project list
# Deploy production
npx wrangler pages deploy ./dist
# Deploy preview
npx wrangler pages deploy ./dist --branch=feature-x
# List deployments
npx wrangler pages deployment list --project-name=my-app
API Deployment
# Create deployment via API
curl -X POST \
"https://api.cloudflare.com/client/v4/accounts/{account_id}/pages/projects/{project_name}/deployments" \
-H "Authorization: Bearer {api_token}" \
-F "manifest=@manifest.json" \
-F "file1=@dist/index.html"
Local Development
Wrangler Dev Server
# Basic development
npx wrangler pages dev ./dist
# With bindings
npx wrangler pages dev ./dist \
--kv=MY_KV \
--r2=BUCKET \
--d1=DB=<database-id> \
--port=8788
# With live reload (framework dev server)
npx wrangler pages dev -- npm run dev
# Proxy to another server
npx wrangler pages dev --proxy=3000
# List deployments
npx wrangler pages deployment list --project-name=my-app
# Rollback (redeploy a previous deployment)# Note: Direct rollback command not available;# redeploy the specific commit or use dashboard
Troubleshooting
Build Failures
Error: Build command failed
Solutions:
Check build logs for specific error
Verify build command and output directory
Test locally: npm run build
Check Node.js version compatibility
Review environment variables
Function 500 Errors
Error: Internal Server Error
Solutions:
Check function logs in dashboard
Verify bindings are configured
Test locally with wrangler pages dev
Check for unhandled promise rejections
Static Asset 404
Error: Page not found
Solutions:
Verify build output directory is correct
Check _routes.json isn't excluding the path
Confirm file exists in build output
Review _redirects for conflicts
Binding Not Found
Error: Cannot read property of undefined
Solutions:
Verify binding is configured in dashboard
Check binding name matches code
For local dev, pass binding flags to wrangler
Verify wrangler.toml configuration
Headers/Redirects Not Working
Possible causes:
File not in correct location (must be in build output)