Skip to main content

Cloudflare Worker Example

This example demonstrates a complete Cloudflare Worker application with multiple advanced features including Durable Objects, Workflows, Service Bindings (RPC), R2 Buckets, Queues, and AI Search.

Features

  • Worker: Main HTTP handler with multiple bindings
  • Durable Objects: Stateful objects with SQLite storage
  • Workflows: OFAC workflow processing
  • RPC Worker: Service-to-service communication
  • R2 Bucket: Object storage
  • Queue: Message queue for async processing
  • AI Search: Vector search on R2 bucket contents

Project Setup

Key Features Explained

Durable Objects with SQLite

The example uses Durable Objects with SQLite storage enabled:

Queue Event Source

The worker is configured to process queue messages:

AI Search on R2

Vector search is enabled on the R2 bucket:

RPC Service Binding

Workers can communicate via typed RPC:

Source Code

View the complete source code: examples/cloudflare-worker