# @askrjs/askr/actions

> Published API exports for @askrjs/askr/actions.

Source: [https://askrjs.com/docs/reference/api/askr/actions](https://askrjs.com/docs/reference/api/askr/actions)

Status: stable. Packages: @askrjs/askr/actions.

**Published packages are authoritative.** Examples may lag behind a published contract. When guidance differs, verify the exports and TypeScript declarations in your installed package, then file an issue.

## Exports

This entrypoint publishes 6 exports from the declarations shipped by @askrjs/askr.

### `action`

```ts
action: <TInput extends Record<string, unknown>, TResult = unknown>(descriptor: ActionDescriptor<TInput>) => { state: StateTuple<ActionStatus<TResult>>; submit(input: TInput): Promise<TResult>; }
```

Returns a command handle, rather than a hook.

### `ActionDescriptor`

```ts
ActionDescriptor: any
```

A declared server action, built by {@link defineAction}, bound to a form via {@link ActionForm}.

- `id`: readonly id: string;

- `input`: readonly input: ObjectSchema<TInput>;

- `invalidates`: readonly invalidates: readonly string[];

### `ActionForm`

```ts
ActionForm: <TInput extends Record<string, unknown>>({ action, children, ...props }: { readonly action: ActionDescriptor<TInput>; readonly children?: RenderableChild; readonly [key: string]: unknown; }) => JSXElement
```

A native form bound to a declared action; it is not a synthetic event API.

### `ActionStatus`

```ts
ActionStatus: any
```

Pending/result/error status for an action, as reported by the `action()` hook.

- `pending`: readonly pending: boolean;

- `result`: readonly result?: TResult;

- `error`: readonly error?: unknown;

### `ActionValidationError`

```ts
ActionValidationError: any
```

Server-replayed validation failure for an {@link ActionForm} submission.

- `kind`: readonly kind: 'invalid';

- `action`: readonly action: string;

- `values`: readonly values: Readonly<Record<string, unknown>>;

- `issues`: readonly issues: readonly unknown[];

- `fieldErrors`: readonly fieldErrors: Readonly<Record<string, readonly string[]>>;

### `defineAction`

```ts
defineAction: <TInput extends Record<string, unknown>>(options: { readonly id: string; readonly input: ObjectSchema<TInput>; readonly invalidates?: readonly string[]; }) => ActionDescriptor<TInput>
```

Declare a server action with a stable id, input schema, and query prefixes to invalidate on success.

## Documentation navigation

[Previous](https://askrjs.com/docs/reference/api/askr/router/index.md) | [Next](https://askrjs.com/docs/reference/api/askr/ssr/index.md)
