Deployment Guide
Deploy experiments to Cloudflare Workers using click-to-deploy or manual methods
Every experiment in this repository can be deployed independently to Cloudflare Workers. This guide covers all deployment methods and configuration steps.
Quick Deploy (Click-to-Deploy)
The fastest way to deploy any experiment is using Cloudflare's one-click deployment:
Choose an experiment
Navigate to any experiment page and click the "Deploy to Cloudflare Workers" button.
Each experiment README includes a deploy button linking to its source code.
Authenticate with Cloudflare
Sign in to your Cloudflare account or create one if you don't have an account.
The deployment system will request permissions to deploy Workers on your behalf.
Configure resources
Some experiments require additional resources:
- D1 databases: Created automatically during deployment
- KV namespaces: Created automatically
- R2 buckets: Created automatically
- Browser Rendering: Enabled automatically (requires plan upgrade)
- Workers AI: Enabled automatically (requires plan upgrade)
The deployment wizard guides you through any required setup.
Deploy
Click the final deploy button. Your Worker will be deployed to a *.workers.dev subdomain.
The deployment typically completes in 10-30 seconds.
Deployment URL Format
Click-to-deploy URLs follow this pattern:
https://deploy.workers.cloudflare.com/?url=https://github.com/{owner}/{repo}/tree/{branch}/apps/experiments/{experiment-name}Example:
https://deploy.workers.cloudflare.com/?url=https://github.com/shrinathsnayak/cloudflare-experiments/tree/main/apps/experiments/ai-website-summaryTo deploy from your own fork, replace shrinathsnayak with your GitHub username in the deployment URL.
Manual Deployment
For more control or local development, deploy manually using Wrangler CLI.
Install the required tools:
# Install Node.js 18+ (via nvm recommended)
nvm install 18
nvm use 18
# Install Wrangler CLI globally
npm install -g wrangler
# Authenticate with Cloudflare
wrangler loginClone the repository:
git clone https://github.com/shrinathsnayak/cloudflare-experiments.git
cd cloudflare-experimentsCustom Domains
Add a custom domain to any deployed Worker:
Add domain to Cloudflare
Ensure your domain is already added to Cloudflare and using Cloudflare nameservers.
Navigate to Workers & Pages
In the Cloudflare dashboard:
- Go to Workers & Pages
- Select your deployed Worker
- Click the Triggers tab
Add custom domain
- Click Add Custom Domain
- Enter your subdomain (e.g.,
api.example.com) - Click Add Custom Domain
Cloudflare automatically creates DNS records and provisions SSL certificates.
Environment Variables
Some experiments require environment variables. Set them in the dashboard or via Wrangler:
- Go to Workers & Pages 2. Select your Worker 3. Go to Settings → Variables 4. Add variables (Plain text or Secret) 5. Click Save
Deployment Checklist
Verify local functionality
npm run dev
# Test all endpointsCheck TypeScript
npm run build
# or: tsc --noEmitCreate required resources
- D1 databases
- KV namespaces
- R2 buckets
- Set environment variables
Run migrations (if applicable)
npm run db:migrateDeploy
npm run deployTest production
curl https://your-worker.workers.devTroubleshooting
Deployment Fails
- Authentication error: Run
wrangler loginto re-authenticate - Missing binding: Check
wrangler.jsonfor correct binding configuration - TypeScript errors: Run
npm run buildto identify issues
Runtime Errors
- AI binding not found: Ensure Workers AI is enabled on your account
- Browser binding not found: Enable Browser Rendering in your account
- Database not found: Check D1 database_id in
wrangler.json - KV not found: Check KV namespace id in
wrangler.json - R2 not found: Verify bucket names in
wrangler.json
Local Development Issues
- AI doesn't work locally: Use
npm run dev -- --remotefor Workers AI - Browser doesn't work locally: Use
npm run dev -- --remotefor Browser Rendering - R2 public URLs don't work: Use
npm run dev -- --remoteto test with real R2
Production Best Practices
Use Environment Variables
Store sensitive values as secrets, not in code:
wrangler secret put API_KEYSet Rate Limits
Use Cloudflare's Rate Limiting to prevent abuse: Configure in the Cloudflare dashboard under Security.
Monitor Usage
Track Worker invocations and errors: Workers & Pages → Your Worker → Metrics
Enable Analytics
Use Workers Analytics for detailed insights:
Available on Workers Paid plan