DispatchNamespace
Source:
src/Cloudflare/WorkersForPlatforms/DispatchNamespace.ts
A Workers for Platforms dispatch namespace — a container for customer (“user”) Workers that a platform Worker dispatches to at runtime via a dynamic-dispatch binding.
The namespace has no mutable properties: its name is its identity, so
changing the name triggers a replacement. Deleting a namespace also
deletes every script uploaded into it.
Note: Workers for Platforms is a paid add-on. On accounts without the subscription, namespace creation fails with an entitlement error.
Creating a Dispatch Namespace
Section titled “Creating a Dispatch Namespace”Namespace with a generated name
const namespace = yield* Cloudflare.DispatchNamespace("Customers", {});Namespace with an explicit name
const namespace = yield* Cloudflare.DispatchNamespace("Customers", { name: "my-platform-customers",});Uploading user Workers
Section titled “Uploading user Workers”const script = yield* Cloudflare.DispatchNamespaceScript("CustomerA", { namespace: namespace.name, script: `export default { fetch() { return new Response("hi"); } }`,});