cf deploy command deploys applications and resources to Cloudflare’s edge network.
Usage
Resource types
Worker deployment
Deploy a Cloudflare Worker script to the edge.Flags
Worker name. This is the unique identifier for your Worker.
Path to the Worker script file (JavaScript or TypeScript).
Compatibility date for the Worker runtime (e.g.,
2024-01-01). Determines which features and behaviors are available.Worker routes. Can specify multiple routes by repeating the flag. Example:
example.com/*KV namespace bindings in the format
BINDING=namespace-id. Can specify multiple bindings.R2 bucket bindings in the format
BINDING=bucket-name. Can specify multiple bindings.D1 database bindings in the format
BINDING=database-id. Can specify multiple bindings.Environment variables in the format
KEY=value. Can specify multiple variables.Examples
Output
Pages deployment
Deploy static assets to Cloudflare Pages.Flags
Pages project name. Must be an existing project or create one first with
cf create pages.Directory containing the built static assets to deploy.
Git branch name. Used to determine if this is a production or preview deployment.
Git commit hash for deployment tracking.
Git commit message for deployment context.
Examples
Output
Creating resources
Before deploying, you may need to create supporting resources:Create Pages project
Project name for the new Pages project.
The Git branch to use for production deployments.
Build command to run (e.g.,
npm run build).Output directory from the build command (e.g.,
dist or build).Create KV namespace
KV namespace name.
Create D1 database
D1 database name.
Create R2 bucket
R2 bucket name.
Location hint for optimal performance. Options:
wnam (Western North America), enam (Eastern North America), weur (Western Europe), eeur (Eastern Europe), apac (Asia-Pacific).Create Cloudflare Tunnel
Tunnel name.
Create DNS record
Zone name or ID (e.g.,
example.com).DNS record type:
A, AAAA, CNAME, MX, TXT, NS, SRV, CAA, etc.DNS record name (e.g.,
www, api, or @ for root).Record content (e.g., IP address for A records, domain for CNAME).
Time-to-live in seconds. Use
1 for automatic.Whether to proxy the record through Cloudflare (orange cloud).
Priority for MX records.
Deleting resources
Delete Worker
Delete Pages project
Delete KV namespace
Delete D1 database
Delete R2 bucket
Delete Tunnel
Delete DNS record
Listing resources
View your existing Cloudflare resources:Complete deployment example
Here’s a complete workflow for deploying a Worker with all supporting resources:Common authentication flags
Cloudflare account ID. Can also be set via
CLOUDFLARE_ACCOUNT_ID or in config file.Cloudflare API token. Can also be set via
CLOUDFLARE_API_TOKEN or in config file.Enable debug output for troubleshooting.
Error handling
Common errors and solutions:API token is required
API token is required
Error:
cloudflare API token is requiredSolution: Provide your API token via:--api-tokenflagCLOUDFLARE_API_TOKENenvironment variablecloudflare.api_tokenin~/.clanker.yaml
Failed to deploy worker
Failed to deploy worker
Error:
failed to deploy worker: <error details>Solutions:- Verify your script syntax is valid
- Check that all bindings reference existing resources
- Ensure your API token has Worker deployment permissions
- Use
--debugflag to see detailed error information
Zone not found
Zone not found
Error:
failed to find zoneSolutions:- Verify the zone name is correct
- Ensure the zone exists in your Cloudflare account
- Check your API token has permission to access the zone
Next steps
Natural language queries
Query your deployments using natural language
Cloudflare overview
Learn about all Cloudflare commands
Configuration
Configure default Cloudflare settings
Provider guide
Deep dive into Cloudflare integration