Use SuperForm in your app
Typed schemas and reactive form helpers for React.
Define and connect a schema
Create the schema with the core entry point, then pass it directly to useForm from the React entry point. The hook returns input registration helpers and validation state.
The example below follows the package README: useForm receives the schema directly, not an options object. The schema's _type property provides the inferred value type.
| Method / field | Type | Notes |
|---|---|---|
superform.string() | String schema | Supports documented rules such as email(), min(length), max(length), and async(asyncFn). |
superform.number() | Number schema | Supports min(value), max(value), and asynchronous validation. |
superform.object({...}) | Object schema | Compose fields into a schema whose value type can be inferred. |
useForm(schema) | React hook | Returns register, handleSubmit, errors, values, and isSubmitting. |
Register inputs and handle submission
Register each input with its schema field name. Wrap the submit callback with handleSubmit so validation runs before your application handles the values.
In Next.js App Router, render a component that calls useForm from a client component. Show the relevant errors next to their fields and use isSubmitting to prevent duplicate submissions while async submission work is running.
The snippet mirrors the documented API. Adjust the visible labels and submit logic to match your own product; do not rely on browser validation alone for security-sensitive data.