--- id: FormApi title: FormApi --- Defined in: [packages/form-core/src/FormApi.ts:954](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L954) A class representing the Form API. It handles the logic and interactions with the form state. Normally, you will not need to create a new `FormApi` instance directly. Instead, you will use a framework hook/function like `useForm` or `createForm` to create a new instance for you that uses your framework's reactivity model. However, if you need to create a new instance manually, you can do so by calling the `new FormApi` constructor. ## Type Parameters ### TFormData `TFormData` ### TOnMount `TOnMount` *extends* `undefined` \| `FormValidateOrFn`\<`TFormData`\> ### TOnChange `TOnChange` *extends* `undefined` \| `FormValidateOrFn`\<`TFormData`\> ### TOnChangeAsync `TOnChangeAsync` *extends* `undefined` \| `FormAsyncValidateOrFn`\<`TFormData`\> ### TOnBlur `TOnBlur` *extends* `undefined` \| `FormValidateOrFn`\<`TFormData`\> ### TOnBlurAsync `TOnBlurAsync` *extends* `undefined` \| `FormAsyncValidateOrFn`\<`TFormData`\> ### TOnSubmit `TOnSubmit` *extends* `undefined` \| `FormValidateOrFn`\<`TFormData`\> ### TOnSubmitAsync `TOnSubmitAsync` *extends* `undefined` \| `FormAsyncValidateOrFn`\<`TFormData`\> ### TOnDynamic `TOnDynamic` *extends* `undefined` \| `FormValidateOrFn`\<`TFormData`\> ### TOnDynamicAsync `TOnDynamicAsync` *extends* `undefined` \| `FormAsyncValidateOrFn`\<`TFormData`\> ### TOnServer `TOnServer` *extends* `undefined` \| `FormAsyncValidateOrFn`\<`TFormData`\> ### TSubmitMeta `TSubmitMeta` = `never` ## Constructors ### Constructor ```ts new FormApi(opts?): FormApi; ``` Defined in: [packages/form-core/src/FormApi.ts:1073](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1073) Constructs a new `FormApi` instance with the given form options. #### Parameters ##### opts? [`FormOptions`](../interfaces/FormOptions.md)\<`TFormData`, `TOnMount`, `TOnChange`, `TOnChangeAsync`, `TOnBlur`, `TOnBlurAsync`, `TOnSubmit`, `TOnSubmitAsync`, `TOnDynamic`, `TOnDynamicAsync`, `TOnServer`, `TSubmitMeta`\> #### Returns `FormApi`\<`TFormData`, `TOnMount`, `TOnChange`, `TOnChangeAsync`, `TOnBlur`, `TOnBlurAsync`, `TOnSubmit`, `TOnSubmitAsync`, `TOnDynamic`, `TOnDynamicAsync`, `TOnServer`, `TSubmitMeta`\> ## Properties ### baseStore ```ts baseStore: Store>; ``` Defined in: [packages/form-core/src/FormApi.ts:986](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L986) *** ### fieldInfo ```ts fieldInfo: Partial, FieldInfo>> = {}; ``` Defined in: [packages/form-core/src/FormApi.ts:1042](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1042) A record of field information for each field in the form. *** ### fieldMetaDerived ```ts fieldMetaDerived: Store, AnyFieldLikeMeta>>>; ``` Defined in: [packages/form-core/src/FormApi.ts:1001](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1001) *** ### formGroupApis ```ts formGroupApis: Set; ``` Defined in: [packages/form-core/src/FormApi.ts:1048](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1048) The set of currently-mounted `FormGroupApi` instances belonging to this form. Used by `FieldApi.validate` to cascade field-level changes into the validators of any group that encompasses the field. *** ### formGroupMetaDerived ```ts formGroupMetaDerived: ReadonlyStore>; ``` Defined in: [packages/form-core/src/FormApi.ts:1023](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1023) A derived store of every mounted `FormGroupApi`'s `meta`, keyed by group name. Mirrors `fieldMetaDerived` for fields: per-group `meta` is computed once on the form (from `baseStore.formGroupStateBase`, `fieldMetaDerived`, and the registered `formGroupApis`) so reads from a `FormGroupApi.store` instance stay minimal. *** ### options ```ts options: FormOptions = {}; ``` Defined in: [packages/form-core/src/FormApi.ts:971](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L971) The options for the form. *** ### store ```ts store: ReadonlyStore>; ``` Defined in: [packages/form-core/src/FormApi.ts:1024](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1024) ## Accessors ### formId #### Get Signature ```ts get formId(): string; ``` Defined in: [packages/form-core/src/FormApi.ts:1629](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1629) ##### Returns `string` *** ### state #### Get Signature ```ts get state(): FormState; ``` Defined in: [packages/form-core/src/FormApi.ts:1049](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1049) ##### Returns [`FormState`](../interfaces/FormState.md)\<`TFormData`, `TOnMount`, `TOnChange`, `TOnChangeAsync`, `TOnBlur`, `TOnBlurAsync`, `TOnSubmit`, `TOnSubmitAsync`, `TOnDynamic`, `TOnDynamicAsync`, `TOnServer`\> ## Methods ### \_handleSubmit() ```ts _handleSubmit(submitMeta?): Promise; ``` Defined in: [packages/form-core/src/FormApi.ts:2420](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L2420) Handles the form submission, performs validation, and calls the appropriate onSubmit or onSubmitInvalid callbacks. #### Parameters ##### submitMeta? `TSubmitMeta` #### Returns `Promise`\<`void`\> *** ### clearFieldValues() ```ts clearFieldValues(field, options?): void; ``` Defined in: [packages/form-core/src/FormApi.ts:2903](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L2903) Clear all values within an array field. #### Type Parameters ##### TField `TField` *extends* `string` #### Parameters ##### field `TField` ##### options? `UpdateMetaOptions` #### Returns `void` #### Implementation of ```ts FormLikeAPI.clearFieldValues ``` *** ### deleteField() ```ts deleteField(field): void; ``` Defined in: [packages/form-core/src/FormApi.ts:2691](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L2691) #### Type Parameters ##### TField `TField` *extends* `string` #### Parameters ##### field `TField` #### Returns `void` #### Implementation of ```ts FormLikeAPI.deleteField ``` *** ### getAllErrors() ```ts getAllErrors(): object; ``` Defined in: [packages/form-core/src/FormApi.ts:3026](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L3026) Returns form and field level errors #### Returns `object` ##### fields ```ts fields: Record, { errorMap: ValidationErrorMap; errors: ValidationError[]; }>; ``` ##### form ```ts form: object; ``` ###### form.errorMap ```ts errorMap: ValidationErrorMap, UnwrapFormValidateOrFn, UnwrapFormAsyncValidateOrFn, UnwrapFormValidateOrFn, UnwrapFormAsyncValidateOrFn, UnwrapFormValidateOrFn, UnwrapFormAsyncValidateOrFn, UnwrapFormValidateOrFn, UnwrapFormAsyncValidateOrFn, UnwrapFormAsyncValidateOrFn>; ``` ###### form.errors ```ts errors: NonNullable< | UnwrapFormValidateOrFn | UnwrapFormValidateOrFn | UnwrapFormAsyncValidateOrFn | UnwrapFormValidateOrFn | UnwrapFormAsyncValidateOrFn | UnwrapFormValidateOrFn | UnwrapFormAsyncValidateOrFn | UnwrapFormValidateOrFn | UnwrapFormAsyncValidateOrFn | UnwrapFormAsyncValidateOrFn>[]; ``` *** ### getFieldInfo() ```ts getFieldInfo(field): FieldInfo; ``` Defined in: [packages/form-core/src/FormApi.ts:2595](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L2595) Gets the field info of the specified field. #### Type Parameters ##### TField `TField` *extends* `string` #### Parameters ##### field `TField` #### Returns `FieldInfo`\<`TFormData`\> *** ### getFieldMeta() ```ts getFieldMeta(field): AnyFieldLikeMeta | undefined; ``` Defined in: [packages/form-core/src/FormApi.ts:2577](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L2577) Gets the metadata of the specified field. #### Type Parameters ##### TField `TField` *extends* `string` #### Parameters ##### field `TField` #### Returns `AnyFieldLikeMeta` \| `undefined` #### Implementation of ```ts FormLikeAPI.getFieldMeta ``` *** ### getFieldValue() ```ts getFieldValue(field): DeepValue; ``` Defined in: [packages/form-core/src/FormApi.ts:2570](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L2570) Gets the value of the specified field. #### Type Parameters ##### TField `TField` *extends* `string` #### Parameters ##### field `TField` #### Returns [`DeepValue`](../type-aliases/DeepValue.md)\<`TFormData`, `TField`\> #### Implementation of ```ts FormLikeAPI.getFieldValue ``` *** ### getFormGroupMeta() ```ts getFormGroupMeta(name): AnyFormGroupMeta | undefined; ``` Defined in: [packages/form-core/src/FormApi.ts:2588](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L2588) Gets the derived `meta` of the form group registered at the given name. Mirrors `getFieldMeta` for fields. Returns `undefined` if no `FormGroupApi` with that name is currently mounted. #### Parameters ##### name `string` #### Returns [`AnyFormGroupMeta`](../type-aliases/AnyFormGroupMeta.md) \| `undefined` *** ### handleSubmit() #### Call Signature ```ts handleSubmit(): Promise; ``` Defined in: [packages/form-core/src/FormApi.ts:2411](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L2411) Handles the form submission, performs validation, and calls the appropriate onSubmit or onSubmitInvalid callbacks. ##### Returns `Promise`\<`void`\> ##### Implementation of ```ts FormLikeAPI.handleSubmit ``` #### Call Signature ```ts handleSubmit(submitMeta): Promise; ``` Defined in: [packages/form-core/src/FormApi.ts:2412](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L2412) ##### Parameters ###### submitMeta `TSubmitMeta` ##### Returns `Promise`\<`void`\> ##### Implementation of ```ts FormLikeAPI.handleSubmit ``` *** ### insertFieldValue() ```ts insertFieldValue( field, index, value, options?): Promise; ``` Defined in: [packages/form-core/src/FormApi.ts:2731](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L2731) #### Type Parameters ##### TField `TField` *extends* `string` #### Parameters ##### field `TField` ##### index `number` ##### value [`DeepValue`](../type-aliases/DeepValue.md)\<`TFormData`, `TField`\> *extends* `any`[] ? `any`[] & [`DeepValue`](../type-aliases/DeepValue.md)\<`TFormData`, `TField`\>\[`number`\] : `never` ##### options? `UpdateMetaOptions` #### Returns `Promise`\<`void`\> #### Implementation of ```ts FormLikeAPI.insertFieldValue ``` *** ### mount() ```ts mount(): () => void; ``` Defined in: [packages/form-core/src/FormApi.ts:1658](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1658) #### Returns ```ts (): void; ``` ##### Returns `void` *** ### moveFieldValues() ```ts moveFieldValues( field, index1, index2, options?): void; ``` Defined in: [packages/form-core/src/FormApi.ts:2871](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L2871) Moves the value at the first specified index to the second specified index within an array field. #### Type Parameters ##### TField `TField` *extends* `string` #### Parameters ##### field `TField` ##### index1 `number` ##### index2 `number` ##### options? `UpdateMetaOptions` #### Returns `void` #### Implementation of ```ts FormLikeAPI.moveFieldValues ``` *** ### parseValuesWithSchema() ```ts parseValuesWithSchema(schema): | { fields: Record; form: Record; } | undefined; ``` Defined in: [packages/form-core/src/FormApi.ts:3092](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L3092) Parses the form's values with a given standard schema and returns issues (if any). This method does NOT set any internal errors. #### Parameters ##### schema [`StandardSchemaV1`](../type-aliases/StandardSchemaV1.md)\<`TFormData`, `unknown`\> The standard schema to parse the form values with. #### Returns \| \{ `fields`: `Record`\<`string`, [`StandardSchemaV1Issue`](../interfaces/StandardSchemaV1Issue.md)[]\>; `form`: `Record`\<`string`, [`StandardSchemaV1Issue`](../interfaces/StandardSchemaV1Issue.md)[]\>; \} \| `undefined` *** ### parseValuesWithSchemaAsync() ```ts parseValuesWithSchemaAsync(schema): Promise< | { fields: Record; form: Record; } | undefined>; ``` Defined in: [packages/form-core/src/FormApi.ts:3104](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L3104) Parses the form's values with a given standard schema and returns issues (if any). This method does NOT set any internal errors. #### Parameters ##### schema [`StandardSchemaV1`](../type-aliases/StandardSchemaV1.md)\<`TFormData`, `unknown`\> The standard schema to parse the form values with. #### Returns `Promise`\< \| \{ `fields`: `Record`\<`string`, [`StandardSchemaV1Issue`](../interfaces/StandardSchemaV1Issue.md)[]\>; `form`: `Record`\<`string`, [`StandardSchemaV1Issue`](../interfaces/StandardSchemaV1Issue.md)[]\>; \} \| `undefined`\> *** ### pushFieldValue() ```ts pushFieldValue( field, value, options?): void; ``` Defined in: [packages/form-core/src/FormApi.ts:2715](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L2715) Pushes a value into an array field. #### Type Parameters ##### TField `TField` *extends* `string` #### Parameters ##### field `TField` ##### value [`DeepValue`](../type-aliases/DeepValue.md)\<`TFormData`, `TField`\> *extends* `any`[] ? `any`[] & [`DeepValue`](../type-aliases/DeepValue.md)\<`TFormData`, `TField`\>\[`number`\] : `never` ##### options? `UpdateMetaOptions` #### Returns `void` #### Implementation of ```ts FormLikeAPI.pushFieldValue ``` *** ### removeFieldValue() ```ts removeFieldValue( field, index, options?): Promise; ``` Defined in: [packages/form-core/src/FormApi.ts:2799](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L2799) Removes a value from an array field at the specified index. #### Type Parameters ##### TField `TField` *extends* `string` #### Parameters ##### field `TField` ##### index `number` ##### options? `UpdateMetaOptions` #### Returns `Promise`\<`void`\> #### Implementation of ```ts FormLikeAPI.removeFieldValue ``` *** ### replaceFieldValue() ```ts replaceFieldValue( field, index, value, options?): Promise; ``` Defined in: [packages/form-core/src/FormApi.ts:2768](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L2768) Replaces a value into an array field at the specified index. #### Type Parameters ##### TField `TField` *extends* `string` #### Parameters ##### field `TField` ##### index `number` ##### value [`DeepValue`](../type-aliases/DeepValue.md)\<`TFormData`, `TField`\> *extends* `any`[] ? `any`[] & [`DeepValue`](../type-aliases/DeepValue.md)\<`TFormData`, `TField`\>\[`number`\] : `never` ##### options? `UpdateMetaOptions` #### Returns `Promise`\<`void`\> #### Implementation of ```ts FormLikeAPI.replaceFieldValue ``` *** ### reset() ```ts reset(values?, opts?): void; ``` Defined in: [packages/form-core/src/FormApi.ts:1810](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1810) Resets the form state to the default values. If values are provided, the form will be reset to those values instead and the default values will be updated. #### Parameters ##### values? `TFormData` Optional values to reset the form to. ##### opts? Optional options to control the reset behavior. ###### keepDefaultValues? `boolean` #### Returns `void` *** ### resetField() ```ts resetField(field): void; ``` Defined in: [packages/form-core/src/FormApi.ts:2938](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L2938) Resets the field value and meta to default state #### Type Parameters ##### TField `TField` *extends* `string` #### Parameters ##### field `TField` #### Returns `void` #### Implementation of ```ts FormLikeAPI.resetField ``` *** ### resetFieldMeta() ```ts resetFieldMeta(fieldMeta): Partial>; ``` Defined in: [packages/form-core/src/FormApi.ts:2635](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L2635) resets every field's meta #### Type Parameters ##### TField `TField` *extends* `string` #### Parameters ##### fieldMeta `Partial`\<`Record`\<`TField`, `AnyFieldLikeMeta`\>\> #### Returns `Partial`\<`Record`\<`TField`, `AnyFieldLikeMeta`\>\> *** ### setErrorMap() ```ts setErrorMap(errorMap): void; ``` Defined in: [packages/form-core/src/FormApi.ts:2962](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L2962) Updates the form's errorMap #### Parameters ##### errorMap `FormValidationErrorMap`\<`TFormData`, [`UnwrapFormValidateOrFn`](../type-aliases/UnwrapFormValidateOrFn.md)\<`TOnMount`\>, [`UnwrapFormValidateOrFn`](../type-aliases/UnwrapFormValidateOrFn.md)\<`TOnChange`\>, [`UnwrapFormAsyncValidateOrFn`](../type-aliases/UnwrapFormAsyncValidateOrFn.md)\<`TOnChangeAsync`\>, [`UnwrapFormValidateOrFn`](../type-aliases/UnwrapFormValidateOrFn.md)\<`TOnBlur`\>, [`UnwrapFormAsyncValidateOrFn`](../type-aliases/UnwrapFormAsyncValidateOrFn.md)\<`TOnBlurAsync`\>, [`UnwrapFormValidateOrFn`](../type-aliases/UnwrapFormValidateOrFn.md)\<`TOnSubmit`\>, [`UnwrapFormAsyncValidateOrFn`](../type-aliases/UnwrapFormAsyncValidateOrFn.md)\<`TOnSubmitAsync`\>, [`UnwrapFormValidateOrFn`](../type-aliases/UnwrapFormValidateOrFn.md)\<`TOnDynamic`\>, [`UnwrapFormAsyncValidateOrFn`](../type-aliases/UnwrapFormAsyncValidateOrFn.md)\<`TOnDynamicAsync`\>, [`UnwrapFormAsyncValidateOrFn`](../type-aliases/UnwrapFormAsyncValidateOrFn.md)\<`TOnServer`\>\> #### Returns `void` *** ### setFieldMeta() ```ts setFieldMeta(field, updater): void; ``` Defined in: [packages/form-core/src/FormApi.ts:2614](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L2614) Updates the metadata of the specified field. #### Type Parameters ##### TField `TField` *extends* `string` #### Parameters ##### field `TField` ##### updater [`Updater`](../type-aliases/Updater.md)\<`AnyFieldLikeMetaBase`\> #### Returns `void` #### Implementation of ```ts FormLikeAPI.setFieldMeta ``` *** ### setFieldValue() ```ts setFieldValue( field, updater, opts?): void; ``` Defined in: [packages/form-core/src/FormApi.ts:2651](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L2651) Sets the value of the specified field and optionally updates the touched state. #### Type Parameters ##### TField `TField` *extends* `string` #### Parameters ##### field `TField` ##### updater [`Updater`](../type-aliases/Updater.md)\<[`DeepValue`](../type-aliases/DeepValue.md)\<`TFormData`, `TField`\>\> ##### opts? `UpdateMetaOptions` #### Returns `void` #### Implementation of ```ts FormLikeAPI.setFieldValue ``` *** ### swapFieldValues() ```ts swapFieldValues( field, index1, index2, options?): void; ``` Defined in: [packages/form-core/src/FormApi.ts:2839](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L2839) Swaps the values at the specified indices within an array field. #### Type Parameters ##### TField `TField` *extends* `string` #### Parameters ##### field `TField` ##### index1 `number` ##### index2 `number` ##### options? `UpdateMetaOptions` #### Returns `void` #### Implementation of ```ts FormLikeAPI.swapFieldValues ``` *** ### update() ```ts update(options?): void; ``` Defined in: [packages/form-core/src/FormApi.ts:1732](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1732) Updates the form options and form state. #### Parameters ##### options? [`FormOptions`](../interfaces/FormOptions.md)\<`TFormData`, `TOnMount`, `TOnChange`, `TOnChangeAsync`, `TOnBlur`, `TOnBlurAsync`, `TOnSubmit`, `TOnSubmitAsync`, `TOnDynamic`, `TOnDynamicAsync`, `TOnServer`, `TSubmitMeta`\> #### Returns `void` *** ### validateAllFields() ```ts validateAllFields(cause): Promise; ``` Defined in: [packages/form-core/src/FormApi.ts:1856](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1856) Validates all fields according to the FIELD level validators. This will ignore FORM level validators, use form.validate({ValidationCause}) for a complete validation #### Parameters ##### cause `ValidationCause` #### Returns `Promise`\<`unknown`[]\> #### Implementation of ```ts FormLikeAPI.validateAllFields ``` *** ### validateArrayFieldsStartingFrom() ```ts validateArrayFieldsStartingFrom( field, index, cause): Promise; ``` Defined in: [packages/form-core/src/FormApi.ts:1892](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1892) Validates the children of a specified array in the form starting from a given index until the end using the correct handlers for a given validation type. #### Type Parameters ##### TField `TField` *extends* `string` #### Parameters ##### field `TField` ##### index `number` ##### cause `ValidationCause` #### Returns `Promise`\<`unknown`[]\> #### Implementation of ```ts FormLikeAPI.validateArrayFieldsStartingFrom ``` *** ### validateField() ```ts validateField(field, cause): any[] | Promise; ``` Defined in: [packages/form-core/src/FormApi.ts:1933](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L1933) Validates a specified field in the form using the correct handlers for a given validation type. #### Type Parameters ##### TField `TField` *extends* `string` #### Parameters ##### field `TField` ##### cause `ValidationCause` #### Returns `any`[] \| `Promise`\<`any`[]\> #### Implementation of ```ts FormLikeAPI.validateField ```