useForm hook is the primary way to create and manage forms in TanStack Form for React. It returns an extended FormApi instance with React-specific utilities.
Import
Signature
Parameters
Configuration options for the form
Initial values for the form fields
Unique identifier for the form (used for devtools and debugging)
Default state for the form
If true, always run async validation even when sync validation fails. Defaults to false.
Default debounce time in milliseconds for async validation
If true, allows form submission even when validation fails. Defaults to false.
Form-level validators
Validator that runs when the form mounts
Validator that runs when any field changes
Async validator that runs when any field changes
Debounce time for onChange async validation
Validator that runs when any field loses focus
Async validator that runs when any field loses focus
Debounce time for onBlur async validation
Validator that runs on form submission
Async validator that runs on form submission
Function called when the form is submitted with valid data
Function called when the form is submitted with invalid data
Form-level event listeners
Called when any field value changes
Called when any field loses focus
Called when the form mounts
Called when the form is submitted
Return Value
The form API instance with React-specific extensions
A React component for rendering form fields. It’s a pre-bound version of the standalone Field component.
A React component for subscribing to form state changes
Current form state
Current form field values
Form-level validation errors
Map of errors by validation event
Metadata for all form fields
True when form submission is in progress
True after form has been successfully submitted
True when any validation is in progress
True when form and all fields are valid
True when form can be submitted based on current state
True when any field has been modified
True when no fields have been modified
True when any field has been touched
True when any field has been blurred
Counter for submission attempts
Submit the form. Triggers validation and calls onSubmit if valid.
Reset the form to default values or specified values
Manually trigger validation on all fields
validateField
<TField extends DeepKeys<TFormData>>(field: TField, cause: ValidationCause) => ValidationError[]
Validate a specific field
Get the current value of a field
setFieldValue
<TField extends DeepKeys<TFormData>>(field: TField, updater: Updater<DeepValue<TFormData, TField>>, opts?: UpdateMetaOptions) => void
Set the value of a field
Get metadata for a field
setFieldMeta
<TField extends DeepKeys<TFormData>>(field: TField, updater: Updater<FieldMeta>) => void
Set metadata for a field
pushFieldValue
<TField extends DeepKeys<TFormData>>(field: TField, value: any, opts?: UpdateMetaOptions) => void
Push a value to an array field
insertFieldValue
<TField extends DeepKeys<TFormData>>(field: TField, index: number, value: any, opts?: UpdateMetaOptions) => void
Insert a value into an array field at a specific index
removeFieldValue
<TField extends DeepKeys<TFormData>>(field: TField, index: number, opts?: UpdateMetaOptions) => void
Remove a value from an array field
swapFieldValues
<TField extends DeepKeys<TFormData>>(field: TField, index1: number, index2: number) => void
Swap two values in an array field
replaceFieldValue
<TField extends DeepKeys<TFormData>>(field: TField, index: number, value: any, opts?: UpdateMetaOptions) => void
Replace a value in an array field