Skip to content

DO Transforms API

Starts a typed transform definition. Chain .caller(factory) and/or .callee(factory) to define its two boundaries.

Binds callee options for use in applyTransforms. Parameterless transforms do not take an options argument.

Registers transforms on all async methods or selected methods:

applyTransforms(TargetClass, {
all: [registerTransform(globalTransform, options)],
methods: {
write: [registerTransform(writeTransform, options)],
},
});

The Vite plugin adds typed .with(...) access to configured Durable Object and service bindings.

Manually wraps one RPC target when automatic Vite wrapping is not used.

Manually wraps a Durable Object namespace so stubs returned from it support transforms.

createTransformContextTarget(target, context)

Section titled “createTransformContextTarget(target, context)”

Returns a pipelined RPC target carrying typed context. Expose it from setContext() when caller transforms call next({ context }).

The underlying context-target class. Most integrations should use createTransformContextTarget instead of constructing it directly.

Import from @repo/do-transforms/vite. Reads Wrangler bindings, injects wrappers, and emits generated declarations.

doTransforms({ wrangler: './wrangler.jsonc' })

Place it before cloudflare() in the Vite plugin array.

TransformResulting async return type
betterResultCodecPreserves or rehydrates Result<T, E>
errorBoundaryResult<T, unknown>
abortAsSuccessResult<T | undefined, never>
timeoutOriginal method type
retryOriginal method type
largeObjectStreamOriginal method type

Transform chains validate target compatibility, options, context compatibility, async method names, and transformed return types at compile time.