Skip to content

Commit 655d1e5

Browse files
committed
Document the enable_ctx_exports compat flag.
1 parent 0a11df2 commit 655d1e5

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
_build:
3+
publishResources: false
4+
render: never
5+
list: never
6+
7+
name: "Enable ctx.exports"
8+
sort_date: "2025-09-24"
9+
enable_flag: "enable_ctx_exports"
10+
---
11+
12+
This flag enables [the `ctx.exports` API](/workers/runtime-apis/context/#exports), which contains automatically-configured loopback bindings for your Worker's top-level exports. This allows you to skip configuring explicit bindings for your `WorkerEntrypoint`s and Durable Object namespaces defined in the same Worker.
13+
14+
We may change this API to be enabled by default in the future (regardless of compat date or flags).

src/content/docs/workers/runtime-apis/context.mdx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,15 @@ Here, we've placed a `docId` property in `ctx.props`. The `DocumentApi` class co
6464

6565
## `exports`
6666

67+
:::note[Compatibility flag required]
68+
69+
To use `ctx.exports`, you must use [the `enable_ctx_exports` compatibility flag](/workers/configuration/compatibility-flags#enable-ctxexports).
70+
71+
:::
72+
6773
`ctx.exports` provides automatically-configured "loopback" bindings for all of your top-level exports.
6874

69-
* For each top-level exports that `extends WorkerEntrypoint` (or simply implements a fetch handler), `ctx.exports` automatically contains a [Service Binding](/workers/runtime-apis/bindings/service-bindings).
75+
* For each top-level export that `extends WorkerEntrypoint` (or simply implements a fetch handler), `ctx.exports` automatically contains a [Service Binding](/workers/runtime-apis/bindings/service-bindings).
7076
* For each top-level export that `extends DurableObject` (and which has been configured with storage via a [migration](https://developers.cloudflare.com/durable-objects/reference/durable-objects-migrations/)), `ctx.exports` automatically contains a [Durable Object namespace binding](https://developers.cloudflare.com/durable-objects/api/namespace/).
7177

7278
For example:

0 commit comments

Comments
 (0)