Deploying to Cloudflare Workers
Deploy your Cloudflare Workers + RivetKit app to Cloudflare Workers.
Cloudflare Workers
Minimal Cloudflare Workers + RivetKit example.
Cloudflare Workers + Hono
Cloudflare Workers with Hono router.
Cloudflare Workers + Inline Client
Advanced setup using createInlineClient.
Guide
Prerequisites
- Cloudflare account with Durable Objects enabled
- Wrangler CLI v3
- A Cloudflare Worker app integrated with RivetKit
- See the Cloudflare Workers quickstart or Cloudflare Workers example to get started
Verify RivetKit integration with Cloudflare Workers
Your project should have the following files:
src/index.ts(or similar entry point withcreateHandler)src/registry.ts(or similar actor registry file)wrangler.jsonwith proper Durable Objects and KV namespace configuration
If your project is not integrated with RivetKit yet, follow the Cloudflare Workers quickstart guide or see the Cloudflare Workers example.
Deploy to Cloudflare Workers
Deploy to Cloudflare's global network:
Your worker will be deployed and you'll receive a URL like https://my-rivetkit-worker.workers.dev.
More information on deployments is available in Cloudflare's docs.
Connect and Verify
After running wrangler deploy, note the URL printed in the output (e.g., https://my-rivetkit-worker.workers.dev).
Your RivetKit endpoint will be available at this URL with /rivet appended:
- Example:
https://my-rivetkit-worker.workers.dev/rivet
Use this endpoint URL when configuring your RivetKit client or connecting from the Rivet dashboard.
Advanced
Accessing Environment Bindings
You can access Cloudflare Workers environment bindings directly using the importable env:
Driver Context
The Cloudflare Workers driver provides access to the Durable Object state and environment through the driver context in createVars.
The Cloudflare Workers driver context type is exported as DriverContext from @rivetkit/cloudflare-workers:
While you have access to the Durable Object state, be cautious when directly modifying KV storage or alarms, as this may interfere with RivetKit's internal operations and potentially break actor functionality.