# Generative UI Actions
URL: /docs/api-reference/generative-ui/actions

Register handlers for model-emitted $action payloads and dispatch them from interactive generative UI components.

> For AI agents: a documentation index is available at [llms.txt](/llms.txt). Use `.md` for canonical markdown pages; `.mdx` is kept as a backwards-compatible alias on supported URL paths.

## API Reference

### ActionDispatchContext

Context handed to an [ActionHandler](/docs/api-reference/generative-ui/actions#actionhandler) when an `$action` fires.

- `payload`: `Action` — The action payload. For fire-and-forget actions this is the \`$action\` as the model emitted it. For interactive components (\`Select\`/\`Input\`/ \`DatePicker\`) the user's runtime input is merged in under the reserved \`$input\` key, so the handler sees both the model payload and what the user did; a model-supplied \`value\` field is never clobbered.
  - `type`: `string`

### ActionHandler

Resolves a single `$action.type`. Fire-and-forget actions return `void` or a promise that resolves to it; human-in-the-loop actions return a value the runtime uses to resume the run (see IR doc Open question #2 — the resume value is left as `unknown` and documented per-action). The return value is handed back to `dispatch`'s caller as `unknown`.

```
type ActionHandler = (
  ctx: ActionDispatchContext,
) => unknown | Promise<unknown>;
```

### ActionRegistry

The host-provided map from `$action.type` to [ActionHandler](/docs/api-reference/generative-ui/actions#actionhandler). This is the single dispatch target for `$action` on web, shared by the model `present` renderer, the synthetic `present` produced from A2A/A2UI, and the decoded `block_actions` from Slack. Construct it with [createActionRegistry](/docs/api-reference/generative-ui/actions#createactionregistry) and pass it to `JSONGenerativeUI`.

- `dispatch`: `(action: Action) => unknown`
- `has`: `(type: string) => boolean`

### createActionRegistry

- `handlers`: `Readonly<Record<string, ActionHandler>>`

### emptyActionRegistry

A no-op registry used when no handlers are provided. Dispatch resolves to `undefined` and logs a warning in dev for unknown types, so a model-emitted action with no handler degrades to "does nothing" rather than throwing.

```
const emptyActionRegistry: ActionRegistry;
```