TanStack
Form Composition API Reference

CreateFormHookOptions

Defined in: packages/react-form/src/AppForm/createFormHook.public.ts:65

Configures the components and reusable defaults returned by createFormHook.

Form core resolves defaults against the corresponding local options. Omitted local properties inherit their defaults. Explicit undefined clears listener or invalid-submit defaults only with replaceDefault. Listeners and invalid-submit callbacks can compose using a default wrapper with value and behaviour.

Example

tsx
const { useAppForm } = createFormHook({
  formComponents: {
    SubmitButton,
  },
  fieldComponents: {
    inputs: {
      TextField,
    },
  },
  defaultOptions: {
    forms: {
      errorVisibility: ({ fieldState }) => fieldState.meta.isBlurred,
    },
    fields: {
      listeners: {
        value: [auditListener],
        behaviour: 'defaultFirst',
      },
    },
  },
})

// Form components are flat; field components retain their namespaces:
// <form.SubmitButton />
// <field.inputs.TextField />

Type Parameters

TFormComponents

TFormComponents extends ReactFormComponents

Library-managed. Do not specify explicitly.

TFieldComponents

TFieldComponents extends ReactComponentTree

Library-managed. Do not specify explicitly.

Properties

defaultOptions?

ts
optional defaultOptions?: TanStackFormDefaultOptions;

Defined in: packages/react-form/src/AppForm/createFormHook.public.ts:87

Setup-time defaults for forms, rendered fields and array fields, and form groups. Field defaults also apply to group subfields rendered through either the form or group API.

Omitted local properties inherit their defaults. Explicit undefined clears listener or invalid-submit defaults only with replaceDefault. Listener arrays and invalid-submit callbacks accept { value, behaviour } defaults to select replaceDefault, defaultFirst, or localFirst. Bare defaults use replaceDefault.


fieldComponents

ts
fieldComponents: TFieldComponents;

Defined in: packages/react-form/src/AppForm/createFormHook.public.ts:75


formComponents

ts
formComponents: TFormComponents & CompatibleFormComponents<NoInfer<TFormComponents>, TFormComponents, TFieldComponents>;

Defined in: packages/react-form/src/AppForm/createFormHook.public.ts:69