Skip to content
Source
Sign inSign up
TanStack/form
Open History to see the last commit

useForm.md

32 lines918 Bytes

1---
2id: useForm
3title: useForm
4---
5​
6# Function: useForm()
7​
8```ts
9function useForm<TFormData, TFormValidator>(opts?): FormApi<TFormData, TFormValidator> & ReactFormApi<TFormData, TFormValidator>
10```
11​
12A custom React Hook that returns an extended instance of the `FormApi` class.
13​
14This API encapsulates all the necessary functionalities related to the form. It allows you to manage form state, handle submissions, and interact with form fields
15​
16## Type Parameters
17​
18β€’ **TFormData**
19​
20β€’ **TFormValidator** *extends* `undefined` \| `Validator`\<`TFormData`, `unknown`\> = `undefined`
21​
22## Parameters
23​
24β€’ **opts?**: `FormOptions`\<`TFormData`, `TFormValidator`\>
25​
26## Returns
27​
28`FormApi`\<`TFormData`, `TFormValidator`\> & `ReactFormApi`\<`TFormData`, `TFormValidator`\>
29​
30## Defined in
31​
32[useForm.tsx:56](https://github.com/TanStack/form/blob/a6313b7699753752ae30ff16c169e0b08c2369e8/packages/react-form/src/useForm.tsx#L56)