This directory contains real-world Cloudflare Worker examples that demonstrate various patterns and features supported by FlameFlare.
| Example | Description | Features |
|---|---|---|
hello-world/ |
Simplest possible worker | Basic Response, zero config |
json-api/ |
REST API with routing | JSON responses, URL routing, HTTP methods |
environment-variables/ |
Using env vars and secrets | Environment bindings, secret management |
router-worker/ |
URL routing with CORS | Advanced routing, CORS, HTML/JSON responses |
scheduled-worker/ |
Cron trigger patterns | Scheduled events, dual handlers |
multi-module/ |
Multi-file worker with imports | ES module imports, JSON modules, code splitting |
wasm-module/ |
WASM module import | WebAssembly import, binary modules, WebAssembly.instantiate() |
queue-producer-consumer/ |
Message queue patterns | Queues, producers, consumers, batch processing |
| Example | Description | Features |
|---|---|---|
workflow-basic/ |
Multi-step document signing | Durable steps, sleep, retry config, status tracking |
workflow-events/ |
Event-driven payment verification | waitForEvent, sendEvent, webhook patterns |
workflow-comprehensive/ |
User onboarding pipeline (all features) | Every Workflow API: parallel steps, sleepUntil, conditional branching, dynamic loops, try/catch, NonRetryableError, all instance management |
| Example | Description | Features |
|---|---|---|
order-processing-pipeline/ |
Full e-commerce pipeline (Workers + Queues + Workflows) | All binding types, queue producer/consumer chains, workflow with event waiting, cron triggers, service bindings, multi-worker coordination |
| Example | Description | Features |
|---|---|---|
ai-code-review-council/ |
Multi-agent AI code review with BAML | 3 specialist BAML agents (architecture, security, synthesizer), service bindings, workflow tracking, queue verdict delivery, structured LLM extraction |
ai-pitch-evaluator/ |
Multi-agent startup pitch evaluation with BAML | 4 specialist BAML agents (market, financial, technical, verdict), service bindings, workflow tracking, queue evaluation delivery, investment decision |
| Example | Runtime | Description | Features |
|---|---|---|---|
node-hello-world/ |
Node.js | Node.js runtime basics | Node.js APIs, CommonJS |
deno-hello-world/ |
Deno | Deno runtime basics | ES modules, TypeScript |
bun-hello-world/ |
Bun | Bun runtime basics | Fast startup, Web APIs |
python-hello-world/ |
Python | Python runtime basics | WSGI/ASGI, stdlib |
elixir-hello-world/ |
Elixir | Elixir runtime basics | OTP, Plug |
| Example | Description | Features |
|---|---|---|
ffmpeg-worker/ |
Video processing | CLI tool binding, media processing |
pdf-worker/ |
PDF generation | CLI tool binding, document creation |
-
FlameFlare running locally or deployed (e.g. on Fly.io)
-
API Token: Get your token from the setup output or re-run
cd apps/server && mix run priv/repo/seeds.exs -
FlameFlare CLI: Install the CLI to deploy workers:
# One-time: configure GitHub Packages registry echo "@onixus74:registry=https://npm.pkg.github.com" >> ~/.npmrc echo "//npm.pkg.github.com/:_authToken=YOUR_GITHUB_PAT" >> ~/.npmrc # Install bun add -g @onixus74/flameflare-cli # Log in ff login
All examples use three environment variables. Set these once before deploying or testing:
# --- Pick one ---
# Local development
export FLAMEFLARE_URL="http://localhost:4000/client/v4"
# Production (Fly.io)
export FLAMEFLARE_URL="https://flameflare.fly.dev/client/v4"
# --- Required for both ---
export FLAMEFLARE_API_KEY="your-api-token"
# Fetch your account ID automatically
export FLAMEFLARE_ACCOUNT_ID=$(curl -s "$FLAMEFLARE_URL/accounts" \
-H "Authorization: Bearer $FLAMEFLARE_API_KEY" | jq -r '.result[0].id')Verify the setup:
curl -s "$FLAMEFLARE_URL/user/tokens/verify" \
-H "Authorization: Bearer $FLAMEFLARE_API_KEY"cd examples/hello-world
ff deployThe CLI reads flameflare.toml, discovers all source files, and uploads the worker. If the config includes [triggers].crons, schedules are synced automatically.
# Execute a deployed worker
curl "$FLAMEFLARE_URL/accounts/$FLAMEFLARE_ACCOUNT_ID/workers/hello-world/dispatch" \
-H "Authorization: Bearer $FLAMEFLARE_API_KEY"We recommend exploring examples in this order:
- hello-world - Basic worker structure
- json-api - Request/response handling
- environment-variables - Configuration management
- router-worker - Advanced routing patterns
- scheduled-worker - Cron triggers and scheduled tasks
- multi-module - Multi-file ES module imports
- wasm-module - WebAssembly binary module import
- queue-producer-consumer - Asynchronous task processing
- workflow-basic - Durable multi-step workflow execution
- workflow-events - Event-driven workflows with external webhooks
- workflow-comprehensive - Every Workflow feature in one example
- order-processing-pipeline - Complete interconnected pipeline (Workers + Queues + Workflows + Cron + Service Bindings)
All examples include these standard files:
flameflare.toml- Worker configuration (name, main module, runtime, bindings)src/index.js(orsrc/index.py,src/index.exs, etc.) - Worker entry pointpackage.json- NPM configuration withdeployscriptREADME.md- Example-specific documentation
Each worker can specify its runtime in flameflare.toml:
name = "my-worker"
main = "src/index.js"
compatibility_date = "2024-01-01"
runtime = "javascript" # javascript, node, deno, bun, python, elixir
[vars]
ENVIRONMENT = "production"Supported runtimes:
javascript(default) - Standard Web Workers APInode- Node.js runtime with CommonJS supportdeno- Deno runtime with TypeScript and ES modulesbun- Bun runtime for fast startup and Web APIspython- Python runtime with WSGI/ASGI supportelixir- Elixir runtime with OTP and Plug
Workers can declare a resource profile to control which FLAME pool they execute on. This ensures CPU-heavy workloads get performance CPUs and more memory, while lightweight workers stay on cheaper shared infrastructure.
name = "my-video-processor"
main = "src/index.js"
resource_profile = "dedicated"Supported profiles:
standard(default) - Request/response handlers, API calls, compute, I/O (max_concurrency: 10, 5 min idle)dedicated- Heavy compute, long-running workflows, near-isolation (max_concurrency: 2, 4 hr idle)
Each example supports:
ff deploy- Deploy to FlameFlare using the CLI
Test deployed workers with:
# Basic test
curl "$FLAMEFLARE_URL/accounts/$FLAMEFLARE_ACCOUNT_ID/workers/{worker-name}/dispatch" \
-H "Authorization: Bearer $FLAMEFLARE_API_KEY"
# With custom path (using the /*path splat route)
curl "$FLAMEFLARE_URL/accounts/$FLAMEFLARE_ACCOUNT_ID/workers/{worker-name}/dispatch/api/users" \
-H "Authorization: Bearer $FLAMEFLARE_API_KEY"
# With POST data
curl -X POST "$FLAMEFLARE_URL/accounts/$FLAMEFLARE_ACCOUNT_ID/workers/{worker-name}/dispatch" \
-H "Authorization: Bearer $FLAMEFLARE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"message": "Hello!"}'These examples work on both Cloudflare and FlameFlare. FlameFlare adds multi-runtime support, resource profiles for standard/dedicated workloads, CLI tool bindings, and removes execution time limits. See the FlameFlare for Cloudflare Workers Developers guide for the full comparison.
After deploying examples, visit the FlameFlare dashboard to:
- View all deployed workers
- Monitor execution logs
- Check queue message processing
- View workflow execution steps
- Monitor system metrics
Local: http://localhost:4000/dashboard
Production: https://flameflare.fly.dev/dashboard
- Check individual example READMEs for specific instructions
- View the Getting Started guide
- Verify your API token:
curl -H "Authorization: Bearer $FLAMEFLARE_API_KEY" "$FLAMEFLARE_URL/user/tokens/verify"