Skip to content

DispatchArgs

DispatchArgs<TInput, TUser> = object

Defined in: packages/actions/src/types.ts:117

Arguments for ActionDefinition.dispatch, which lets a parent action invoke a sub-action without constructing a new Request.

The parent passes its already-resolved ActionContext and the typed input directly. This avoids re-running getContext() (and thus the cookie-based session lookup) for the sub-action, which is both faster and eliminates the class of bugs described in issue #185 where a manually-built Request forgets to forward the Cookie header.

const parent = createAction((db, input, ctx) => ({
permissions: [],
async run() {
// No Request needed — ctx is reused directly.
const result = await child.dispatch({ ctx, input: { title: "Hello" } });
return result;
},
}));

TInput

The expected input shape for the target action.

TUser

The shape of the authenticated user object.

ctx: ActionContext<TUser>

Defined in: packages/actions/src/types.ts:119

The parent action’s already-resolved context, reused as-is.


input: TInput

Defined in: packages/actions/src/types.ts:121

Typed input for the sub-action.