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.
Example
Section titled “Example”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 actionexport const action = deletePost.action;// Wrap a loader to inject permissionsexport const loader = deletePost.loader(myLoader);Type Parameters
Section titled “Type Parameters”TInput
Section titled “TInput”TInput
The expected input shape for this action.
TResult
Section titled “TResult”TResult
The return type of the action handler.
TUser
The shape of the authenticated user object.
Properties
Section titled “Properties”action()
Section titled “action()”action: (
args) =>Promise<TResult>
Defined in: packages/actions/src/types.ts:180
React Router action handler. Parses input, resolves context, and runs the operation.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<TResult>
buildOperation()
Section titled “buildOperation()”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.
Parameters
Section titled “Parameters”TInput
ActionContext<TUser>
Returns
Section titled “Returns”Operation<TResult>
client
Section titled “client”client:
ClientDescriptor
Defined in: packages/actions/src/types.ts:192
Opaque descriptor for the useActions client hook.
loader()
Section titled “loader()”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.
Type Parameters
Section titled “Type Parameters”TLoaderData
Section titled “TLoaderData”TLoaderData extends Record<string, Serializable>
Parameters
Section titled “Parameters”loaderFn
Section titled “loaderFn”(args) => Promise<TLoaderData>
Returns
Section titled “Returns”(
args):Promise<TLoaderData&object>
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<TLoaderData & object>