Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Cloudflare platform skill covering Workers, D1, R2, KV, AI, Durable Objects, and security.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/workers-playground/README.md
1# Cloudflare Workers Playground Skill Reference23## Overview45Cloudflare Workers Playground is a browser-based sandbox for instantly experimenting with, testing, and deploying Cloudflare Workers without authentication or setup. This skill provides patterns, APIs, and best practices specifically for Workers Playground development.67**URL:** [workers.cloudflare.com/playground](https://workers.cloudflare.com/playground)89## ⚠️ Playground Constraints1011**Playground is NOT production-equivalent:**12- ✅ Real Workers runtime, instant testing, shareable URLs13- ❌ No TypeScript (JavaScript only)14- ❌ No bindings (KV, D1, R2, Durable Objects)15- ❌ No environment variables or secrets16- ❌ ES modules only (no Service Worker format)17- ⚠️ Safari broken (use Chrome/Firefox)1819**For production:** Use `wrangler` CLI. Playground is for rapid prototyping.2021## Quick Start2223Minimal Worker:2425```javascript26export default {27async fetch(request, env, ctx) {28return new Response('Hello World');29}30};31```3233JSON API:3435```javascript36export default {37async fetch(request, env, ctx) {38const data = { message: 'Hello', timestamp: Date.now() };39return Response.json(data);40}41};42```4344Proxy with modification:4546```javascript47export default {48async fetch(request, env, ctx) {49const response = await fetch('https://example.com');50const modified = new Response(response.body, response);51modified.headers.set('X-Custom-Header', 'added-by-worker');52return modified;53}54};55```5657Import from CDN:5859```javascript60import { Hono } from 'https://esm.sh/hono@3';6162export default {63async fetch(request) {64const app = new Hono();65app.get('/', (c) => c.text('Hello Hono!'));66return app.fetch(request);67}68};69```7071## Reading Order72731. **[configuration.md](configuration.md)** - Start here: playground setup, constraints, deployment742. **[api.md](api.md)** - Core APIs: Request, Response, ExecutionContext, fetch, Cache753. **[patterns.md](patterns.md)** - Common use cases: routing, proxying, A/B testing, multi-module code764. **[gotchas.md](gotchas.md)** - Troubleshooting: errors, browser issues, limits, best practices7778## In This Reference7980- **[configuration.md](configuration.md)** - Setup, deployment, configuration81- **[api.md](api.md)** - API endpoints, methods, interfaces82- **[patterns.md](patterns.md)** - Common patterns, use cases, examples83- **[gotchas.md](gotchas.md)** - Troubleshooting, best practices, limitations8485## Key Features8687**No Setup Required:**88- Open URL and start coding89- No CLI, no account, no config files90- Code executes in real Cloudflare Workers runtime9192**Instant Preview:**93- Live preview pane with browser tab or HTTP tester94- Auto-reload on code changes95- DevTools integration (right-click → Inspect)9697**Share & Deploy:**98- Copy Link generates permanent shareable URL99- Deploy button publishes to production in ~30 seconds100- Get `*.workers.dev` subdomain immediately101102## Common Use Cases103104- **API development:** Test endpoints before wrangler setup105- **Learning Workers:** Experiment with APIs without local environment106- **Prototyping:** Quick POCs for edge logic107- **Sharing examples:** Generate shareable links for bug reports or demos108- **Framework testing:** Import from CDN (Hono, itty-router, etc.)109110## Limitations vs Production111112| Feature | Playground | Production (wrangler) |113|---------|------------|----------------------|114| Language | JavaScript only | JS + TypeScript |115| Bindings | None | KV, D1, R2, DO, AI, etc. |116| Environment vars | None | Full support |117| Module format | ES only | ES + Service Worker |118| CPU time | 10ms (Free plan) | 10ms Free / 30s default, 5min max Paid |119| Custom domains | No | Yes |120| Analytics | No | Yes |121122## See Also123124- [Cloudflare Workers Docs](https://developers.cloudflare.com/workers/)125- [Workers Examples](https://developers.cloudflare.com/workers/examples/)126- [Wrangler CLI](https://developers.cloudflare.com/workers/wrangler/)127- [Workers API Reference](https://developers.cloudflare.com/workers/runtime-apis/)128