Consume the nearest form runtime from context.
- Use it inside components rendered under
<form.Form>when you want to split a form into reusable children without prop drilling - Use it with
<form.FormProvider>when a toolbar, summary panel, sticky footer, or side layout lives outside the actual form wrapper - It returns the same runtime object as
useFormBridge(schema)for the nearest provider - It throws if used outside
<form.Form>or<form.FormProvider>
Use FormProvider outside the form tree
<form.Form> already provides context to everything rendered inside it. Reach for <form.FormProvider> only when a consumer is rendered outside the actual form wrapper but still needs access to submit(), state, watch(), or fieldController().
Return value
The hook returns the same runtime surface as the nearest useFormBridge(schema) call.
Complete hook return surface. Every value listed below is returned by useFormBridge() in the exact order shown in the code snippet above, with a link to its dedicated reference section:
| Method | Type | Description |
|---|---|---|
| FormProvider | ComponentType | Advanced context wrapper for consumers rendered outside <Form> |
| Form | ComponentType & { Submit } | Generated wrapper component with submit lifecycle (includes Form.Submit) |
| fields | Record<name, Component> | Typed generated field components keyed by schema name |
| FieldError | ComponentType<{ name }> | Standalone error renderer for one field name |
| FieldLabel | ComponentType<{ name }> | Standalone label renderer for one field name |
| fieldController | (name) => Controller | Field-scoped runtime for fully custom UI while keeping the schema contract |
| state | FormState | Reactive FormState object (values, errors, touched, dirty, isValid, isSubmitting, …) |
| visibility | Record<name, Flags> | Per-field visibility / required / disabled state computed from conditional rules |
| isLoadingDraft | boolean | true while a persisted draft is being restored |
| hasDraft | boolean | true once a draft was found and restored |
| clearDraft | () => void | Delete the saved draft |
| saveDraftNow | () => void | Persist immediately without waiting for debounce |
| setValue | (name, value) => void | Set one field value programmatically |
| getValue | (name) => value | Read one field value |
| getValues | () => Values | Read the full value object |
| validate | (names?) => Promise<boolean> | Validate one field, several fields, or the full form |
| resetFields | (values?) => void | Reset to schema defaults or a provided partial value object |
| setError | (name, message) => void | Push a manual field error |
| clearErrors | (name?) => void | Clear one field, many fields, or all errors |
| watch | (name) => value | Reactive single-field read |
| watchAll | () => Values | Reactive full-value read |
| submit | () => Promise<void> | Imperative submit using the same submit pipeline as Form.Submit |
Rules & composition notes
- The hook must run below the nearest
<form.Form>or<form.FormProvider> - The nearest provider wins, so nested form providers isolate their own runtime
- Prefer plain props when one small child needs one value; prefer context when several descendants need coordinated access to the form runtime
watch(),watchAll(),state, andvisibilityremain reactive because the provider shares the live form api object- If a consumer needs to trigger submission from outside the rendered form element,
<form.FormProvider>is the intended path