The Cloudflare Workers platform with Durable Objects provides a robust environment for running ActorCore at the edge.

ActorCore is still pre-v1.0. Please help us by report bugs on GitHub Issues!

Deploy

1

Start with framework

Start with your framework of choice:

2

Install dependencies

Install the Cloudflare Workers platform package:

npm install @actor-core/cloudflare-workers
3

Create your server

Create a file src/index.ts to handle Cloudflare Workers integration:

src/index.ts
import { createHandler } from "@actor-core/cloudflare-workers";
import { app } from "../actors/app";

// Create handlers for Cloudflare Workers
const { handler, ActorHandler } = createHandler(app);

// Export the handlers for Cloudflare
export { handler as default, ActorHandler };
4

Create KV namespace

Create a KV namespace for your actors:

npx wrangler kv:namespace create ACTOR_KV

Take note of the KV namespace ID from the output, as you’ll need it in the next step.

5

Configure Wrangler

Create a wrangler.jsonc configuration and add your KV namespace ID from the previous step:

wrangler.jsonc
{
  "$schema": "node_modules/wrangler/config-schema.json",
  "name": "my-app",
  "main": "src/index.ts",
  "compatibility_date": "2025-04-04",
  "observability": {
    "enabled": true
  },
  "migrations": [
    {
      "tag": "v1",
      "new_classes": ["ActorHandler"]
    }
  ],
  "durable_objects": {
    "bindings": [
      {
        "name": "ACTOR_DO",
        "class_name": "ActorHandler"
      }
    ]
  },
  "kv_namespaces": [
    {
      "binding": "ACTOR_KV",
      "id": "your-namespace-id-here"  // Replace with your actual ID
    }
  ]
}
6

Deploy to production

Deploy your project to Cloudflare Workers:

npx wrangler deploy

Your ActorCore application will be available at your Cloudflare Workers URL.

7

Update your client's endpoint

Update your client to connect to your deployed app:

const client = createClient<App>(/* FILL ME IN */);

CORS Configuration

For security reasons, you should configure proper CORS settings in production. In the example above, we used cors: { origin: "*" } which allows requests from any domain.

For production deployments, specify the exact domains that should be allowed to connect to your actors. Learn more in the CORS documentation.

Integration with Existing Projects

If you already have an existing application and want to mount ActorCore on a subpath, see our Hono integration guide. Remember to specify the same path in config.basePath as where you mount the router.

Accessing Cloudflare Context And Bindings

You can access Cloudflare-specific features like the DurableObjectState and environment bindings from your actor:

import { actor } from "actor-core";

const myActor = actor({
  // Load Cloudflare-specific variables
  createVars: (c, cloudflare) => ({
    ctx: cloudflare.ctx,
    env: cloudflare.env,
  }),
  actions: {
    foo: async (c) => {
      // Access DurableObjectState
      await c.vars.ctx.storage.get("foo");

      // Access bindings
      await c.vars.env.MY_BUCKET.put(key, "foo");
    },
  }
});

Available Regions

See available regions here.

Cloudflare does not guarantee your code will run in the requested region.

Next Steps