cloudflare · Cloudflare Workers Docs
Workers Context (ctx)
Explains how to use the Context API in Cloudflare Workers to manage lifecycle events via waitUntil and passThroughOnException, and how to pass authenticated configuration data between workers using ctx.props.
Derived skill
Files assembled from official documentation
Viewing SKILL.md
Workers Context (ctx)
Explains how to use the Context API in Cloudflare Workers to manage lifecycle events via waitUntil and passThroughOnException, and how to pass authenticated configuration data between workers using ctx.props.
When To Use
Use when you need to extend a worker's lifecycle to complete background tasks or when you need to pass trusted configuration data between workers using service bindings.
Reference Files
| File | Contains | Use For |
|---|---|---|
SKILL.md | Entry point: scope, routing table, and workflow. | Start here. |
docs/workers-runtime-apis-context-ctx-workflow-guide.md | A technical reference documenting the Cloudflare Workers Context API, including its lifecycle management methods, handler parameters, and TypeScript types for ctx.props and ctx.exports. | Questions about a technical reference documenting the Cloudflare Workers Context API, including its lifecycle management methods, han... |
examples/workers-runtime-apis-context-ctx-cloudflare-workers-context-ctx-service-.text | A text representation of the Workers Context object demonstrating service binding configuration and properties. | Exact payloads, commands, or snippets shown in A text representation of the Workers Context object demonstrating service binding configuration and properties. |
examples/workers-runtime-apis-context-ctx-cloudflare-workers-context-services-bin.text | A TOML configuration snippet demonstrating how to define service bindings within the Workers context. | Exact payloads, commands, or snippets shown in A TOML configuration snippet demonstrating how to define service bindings within the Workers context. |
examples/workers-runtime-apis-context-ctx-cloudflare-workers-context-ctx-service--2.text | A text representation of the Workers Context object demonstrating service binding configuration and properties. | Exact payloads, commands, or snippets shown in A text representation of the Workers Context object demonstrating service binding configuration and properties. |
examples/workers-runtime-apis-context-ctx-cloudflare-workers-context-services-bin-2.text | A TOML configuration snippet demonstrating how to define service bindings within the Workers Context. | Exact payloads, commands, or snippets shown in A TOML configuration snippet demonstrating how to define service bindings within the Workers Context. |
examples/workers-runtime-apis-context-ctx-cloudflare-workers-context-ctx-entrypoi.text | A JavaScript code example demonstrating how to use the Workers Context (ctx) object within a WorkerEntrypoint class. | Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating how to use the Workers Context (ctx) object within a WorkerEntrypoint class. |
examples/workers-runtime-apis-context-ctx-cloudflare-workers-context-ctx-entrypoi-2.text | A TypeScript example demonstrating how to use the Workers Context (ctx) object within a WorkerEntrypoint class to access properties and exports. | Exact payloads, commands, or snippets shown in A TypeScript example demonstrating how to use the Workers Context (ctx) object within a WorkerEntrypoint class to acc... |
examples/workers-runtime-apis-context-ctx-cloudflare-workers-context-ctx-entrypoi-3.text | A TypeScript example demonstrating how to use the Workers Context (ctx) object to access properties within a WorkerEntrypoint class. | Exact payloads, commands, or snippets shown in A TypeScript example demonstrating how to use the Workers Context (ctx) object to access properties within a WorkerEn... |
examples/workers-runtime-apis-context-ctx-cloudflare-workers-context-ctx-waitunti.text | A JavaScript example demonstrating the use of the ctx.waitUntil method to perform background tasks in a Cloudflare Worker. | Exact payloads, commands, or snippets shown in A JavaScript example demonstrating the use of the ctx.waitUntil method to perform background tasks in a Cloudflare Wo... |
examples/workers-runtime-apis-context-ctx-cloudflare-workers-context-ctx-passthro.text | A JavaScript code example demonstrating the use of the ctx.passThroughOnException() method within a Cloudflare Workers fetch handler. | Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating the use of the ctx.passThroughOnException() method within a Cloudflare Worker... |
What This Skill Covers
- The Context API provides methods to manage the lifecycle of your Worker or Durable Object.
- Main sections:
props,exports,Specifying ctx.props when using ctx.exports,TypeScript types for ctx.exports and ctx.props,waitUntil.
Workflow
- Open the most relevant file under
docs/for the exact documented workflow and wording. - Open
schemas/files for exact structured contracts. - Open
examples/files for concrete requests, commands, snippets, and manifests. - Do not add behavior or configuration that is not present in the attached source files.
Canonical source: https://developers.cloudflare.com/workers/runtime-apis/context
