Cloudflare Workers (Durable Objects)
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
Start with framework
Start with your framework of choice:
Install dependencies
Install the Cloudflare Workers platform package:
Create your server
Create a file src/index.ts
to handle Cloudflare Workers integration:
Create KV namespace
Create a KV namespace for your actors:
Take note of the KV namespace ID from the output, as you’ll need it in the next step.
Configure Wrangler
Create a wrangler.jsonc
configuration and add your KV namespace ID from the previous step:
Deploy to production
Deploy your project to Cloudflare Workers:
Your ActorCore application will be available at your Cloudflare Workers URL.
Update your client's endpoint
Update your client to connect to your deployed app:
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:
Available Regions
See available regions here.
Cloudflare does not guarantee your code will run in the requested region.