Installation
One binding, one migration line, and one define — each of which
fails in a way that is hard to diagnose if you miss it.
Install
pnpm add @sigx/actors-cloudflare
pnpm add -D wranglerwrangler.jsonc
{
"main": "src/worker.ts",
// Pinned, never floating: a compatibility date is how Workers versions
// runtime behaviour, so bumping it is a deliberate change to test.
"compatibility_date": "2026-07-01",
"compatibility_flags": ["nodejs_compat"],
"durable_objects": {
"bindings": [{ "name": "ACTORS", "class_name": "ActorHost" }]
},
"migrations": [{ "tag": "v1", "new_sqlite_classes": ["ActorHost"] }],
"define": { "__DEV__": "false" },
"observability": { "enabled": true }
}
The three that bite
new_sqlite_classes, notnew_classes— a one-way door.new_classescreates the legacy key-value backed storage, which cannot be migrated to SQLite in place; the class is stuck with it forever, and it carries a far smaller per-value limit. This is the single most consequential irreversible line in the file.
__DEV__must be defined by your bundler. The published package ships both a dev and a production dist and expects the flag to be defined. Without it the host throws__DEV__ is not definedon the first request.pnpm devshould override it totruefor local warnings.
nodejs_compatis required. Interleaving needsAsyncLocalStorage.
The entry
export class ActorHost extends createHostDurableObject<Env>({
actors, namespace: (env) => env.ACTORS, app: createApp,
}) {}
export default createWorkerHandler<Env>({
actors, namespace: (env) => env.ACTORS, app: createApp,
fetch: { origin: false, fallback: servePage },
});
Pass an app factory, not an app — building at module scope binds whichever object
constructed it first. And set origin explicitly: the public mount defaults to refusing a
request with no Origin, and Workers callers send none.
Both are explained in Cloudflare Workers.
Types
Env is worth declaring by hand rather than generating with wrangler types — one binding is
not worth a generated file that has to be committed, kept in step with wrangler.jsonc and
excluded from lint.
export interface Env { ACTORS: DurableObjectNamespace }
Verify
pnpm wrangler dev
Local wrangler dev numbers describe the local harness, not Cloudflare — do not read
performance conclusions from them.
Next steps
- API reference — exports.
- Cloudflare Workers — placement, eviction and alarms.
- Tasks — the checkpoint posture under eviction.
