Skip to content

ActionDefinition

ActionDefinition<TInput, TResult, TUser> = object

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

A single action definition returned by createAction().

Provides four facets: a React Router action handler, a loader wrapper that injects permission status, a client descriptor for useActions, and a buildOperation method for advanced composition.

const deletePost = createAction<{ postId: string }, Response>(
(db, input, ctx) =>
compose(
[db.delete(posts).where(eq(posts.id, input.postId))],
async (runDelete) => { await runDelete({}); return redirect("/"); },
),
);
// Use as a route action
export const action = deletePost.action;
// Wrap a loader to inject permissions
export const loader = deletePost.loader(myLoader);

TInput

The expected input shape for this action.

TResult

The return type of the action handler.

TUser

The shape of the authenticated user object.

action: (args) => Promise<TResult>

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

React Router action handler. Parses input, resolves context, and runs the operation.

RequestArgs

Promise<TResult>


buildOperation: (db, input, ctx) => Operation<TResult>

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

Builds the raw Operation for this action, useful for cross-action composition.

Db

TInput

ActionContext<TUser>

Operation<TResult>


client: ClientDescriptor

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

Opaque descriptor for the useActions client hook.


loader: <TLoaderData>(loaderFn) => (args) => Promise<TLoaderData & object>

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

Wraps a loader function to inject ActionPermissionsMap into its return value.

The wrapper resolves the action context, builds the operation to extract permission descriptors, checks them against the user’s grants, and merges the result as _actionPermissions.

TLoaderData extends Record<string, Serializable>

(args) => Promise<TLoaderData>

(args): Promise<TLoaderData & object>

RequestArgs

Promise<TLoaderData & object>