logoassistant-ui
ReferenceIntegrations

@assistant-ui/react-hook-form

A React Hook Form integration for @assistant-ui.

API Reference

useAssistantForm

Drop-in replacement hook for useForm that adds support for @assistant-ui/react.

- import { useForm } from "react-hook-form";
+ import { useAssistantForm } from "@assistant-ui/react-hook-form";
 
- useForm({
+ useAssistantForm({
    ...
  });

Properties

UseAssistantFormProps

assistant?:

object

Configuration for useAssistantForm

tools?:

object

Tools configuration for useAssistantForm

set_form_field?:

object

Configuration for the set_form_field tool

render?:

ToolCallContentPartComponent<{ name: string; value: string; }, {}>

The component to render when set_form_field is called.

submit_form?:

object

Configuration for the submit_form tool

render?:

ToolCallContentPartComponent<{}, {}>

The component to render when submit_form is called.

formTools

The set of tools to use with useAssistantForm, useful for runtimes that do not support client-side tool definitions (i.e. Vercel AI SDK).

import { formTools } from "@assistant-ui/react-hook-form";
 
const result = streamText({
  ...
  tools: {
    ...formTools,
  }
});

On this page

Edit on Github