Prompt Buddy logoPrompt Buddy

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.

Import to Prompt Buddy

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

FileContainsUse For
SKILL.mdEntry point: scope, routing table, and workflow.Start here.
docs/workers-runtime-apis-context-ctx-workflow-guide.mdA 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-.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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

  1. Open the most relevant file under docs/ for the exact documented workflow and wording.
  2. Open schemas/ files for exact structured contracts.
  3. Open examples/ files for concrete requests, commands, snippets, and manifests.
  4. 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