alepha@docs:~/docs/reference/react-hooks$
cat useForm.md
1 min read
Last commit:

#useForm

#Import

typescript
1import { useForm } from "alepha/react/form";

#Overview

Custom hook to create a form with validation and field management. This hook uses TypeBox schemas to define the structure and validation rules for the form. It provides a way to handle form submission, field creation, and value management.

#Examples

tsx
 1import { t } from "alepha"; 2  3const form = useForm({ 4  schema: t.object({ 5    username: t.text(), 6    password: t.text(), 7  }), 8  handler: (values) => { 9    console.log("Form submitted with values:", values);10  },11});12 13return (14  <form {...form.props}>15    <input {...form.input.username.props} />16    <input {...form.input.password.props} />17    <button type="submit">Submit</button>18  </form>19);