svg

Menu

Illustration of Cloudflare Wrangler CLI logo with terminal commands

Mastering Cloudflare Infrastructure with Wrangler CLI

MAR 23, 20262 MIN READBLOG POST

Master Cloudflare D1, Workers, Pages, and Queues with Wrangler. A complete guide to managing your edge-native CRUD operations from the command line.

This guide focuses on the CLI commands you need to Create, Read (List), Update, and Delete your Cloudflare resources directly from your terminal using wrangler.

Cloudflare D1 (SQL Database)

Terminal window
# Create a new database
wrangler d1 create <db-name>
# List all databases
wrangler d1 list
# Execute a direct SQL query
wrangler d1 execute <db-name> --command "SELECT * FROM users;"
# Apply migrations to production
wrangler d1 migrations apply <db-name> --remote
# Delete a database
wrangler d1 delete <db-name>

Cloudflare Workers (Serverless Functions)

Terminal window
# Initialize a new project
wrangler init <project-name>
# List all deployed workers
wrangler list
# Deploy your worker to the edge
wrangler deploy
# Tail live logs for debugging
wrangler tail <worker-name>
# Delete a worker (run inside project directory)
wrangler delete

Cloudflare Pages (Hosting)

Terminal window
# Create a new Pages project
wrangler pages project create <project-name>
# List all Pages projects
wrangler pages project list
# Deploy a static directory to Pages
wrangler pages deploy <directory-name>
# View live deployment logs
wrangler pages deployment tail
# Delete a Pages project
wrangler pages project delete <project-name>

Cloudflare Queues (Message Broker)

Terminal window
# Create a new queue
wrangler queues create <queue-name>
# List all active queues
wrangler queues list
# Attach a worker as a consumer
wrangler queues consumer add <queue-name> <worker-name>
# Remove a consumer from a queue
wrangler queues consumer remove <queue-name> <worker-name>
# Delete a queue
wrangler queues delete <queue-name>

Cloudflare KV (Key-Value Store)

Terminal window
# Create a new KV namespace
wrangler kv:namespace create <namespace-name>
# List all KV namespaces
wrangler kv:namespace list
# Put a value into KV
wrangler kv:key put --binding=<BINDING> "my-key" "my-value"
# Delete a KV namespace
wrangler kv:namespace delete --binding=<BINDING>

Let’s start architecting your project

Want to see how to transform your brand into a unique style. send me a message

svg