Skip to content
Agentmart
Submit a tool

react-hook-form

Guide for setting up react-hook-form with Zod validation in React.

Skill by Lichens-Innovation

IndexedMIT
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/lichens-innovation-react-hook-form

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Guide for setting up react-hook-form with Zod validation in React. Use this skill whenever the user wants to create a form component, add form validation, wire up Zod schemas to a form, use react-hook-form's Controller, handle form submission, display field errors, or reset/pre-populate a form with existing data. Also use when the user asks how to integrate react-hook-form with a UI component library (Ant Design, MUI, shadcn, etc.) or how to type form values with TypeScript.

Use cases: design, frontend, data

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/react-hook-form

What's inside

Skill name
react-hook-form
Description
Guide for setting up react-hook-form with Zod validation in React. Use this skill whenever the user wants to create a form component, add form validation, wire up Zod schemas to a form, use react-hook-form's Controller, handle form submission, display field errors, or reset/pre-populate a form with existing data. Also use when the user asks how to integrate react-hook-form with a UI component library (Ant Design, MUI, shadcn, etc.) or how to type form values with TypeScript.
License
MIT
Instructions
208 lines in SKILL.md · view on GitHub

Files (2)

  • README.md
  • SKILL.md

SKILL.md (first lines)

# React Hook Form + Zod

A pattern for building validated form components in React using `react-hook-form` and `zod`.

## Installation

```bash
npm install react-hook-form zod @hookform/resolvers
```

## 1. Define a Zod Schema and Infer the Type

Define the schema once and derive the TypeScript type from it — no duplication.

```typescript
import { z } from "zod";

const userSchema = z.object({
  name: z.string().min(1),
  email: z.string().email(),
  role: z.string().optional(),
});

type UserForm = z.infer<typeof userSchema>;
```

## 2. Initialize useForm

Pass the schema to `zodResolver` and type the form with the inferred type.

```typescript
import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";

const {
  control,
  handleSubmit,
  reset,
  formState: { errors },
} = useForm<UserForm>({ resolver: zodResolver(userSchema) });
```

Key destructured values:

| Value | Purpose |
|-------|---------|
| `control` | Passed to `<Controller>` to connect inputs |
| `handleSubmit` | Wraps your submit handler; validates before calling it |
| `reset` | Clears the form or populates it with new values |
| `errors` | Object with validation errors per field |

## 3. Render Fields with Controller

Use `<Controller>` to connect any input — native HTML or a UI library component — to the form.

```tsx
import { Controller } from "react-hook-form";

<Controller
  name="name"
  control={control}
  render={({ field }) => <input {...field} />}
/>
```

The `field` object contains `value`, `onChange`, `onBlur`, and `ref`. Spread it directly onto the input.

## 4. Display Validation Errors

Check `errors.fieldName` to conditionally show error messages.

```tsx
<div>
  <Controller
    name="email"
    control={control}
    render={({ field }) => <input type="email" {...field} />}
  />
  {errors.email && <span>{errors.email.message}</span>}
</div>
```

For UI libraries that accept `validateStatus` / `help` props (e.g. Ant Design):

```tsx
<Form.Item
  validateStatus={errors.email ? "error" : ""}
  help={errors.email?.message}
>
  <Controller name="email" control={control} render={({ field }) => <Input {...field} />} />
</Form.Item>
```

## 5. Handle Submission

Pass your handler to `handleSubmit`. The handler receives fully-typed, validated values.

```typescript
const onSubmit = (values: UserForm) => {
  // values is typed and validated — safe to use directly
  saveUser(values);
};

// Wire to a button or form element:
<button onClick={handleSubmit(onSubmit)}>Save</button>
// or
<form onSubmit={handleSubmit(onSubmit)}>...</form>
```

## 6. Reset and Pre-populate

Call `reset()` to clear the form, or `reset(values)` to fill it with existing data (useful for edit forms).

```typescript
// Clear on cancel
const handleCancel = () => {
  reset();
  onClose();
};

From Lichens-Innovation/ai-dev-tools, MIT.

More from Lichens-Innovation/ai-dev-tools

Signals

Stars
0
Forks
0
Open issues
6
Last commit (this folder)
Oct 11, 2026 (18 days ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from Lichens-Innovation

Cite this page

react-hook-form skill. Agent Mart. https://agentmart.dev/skills/lichens-innovation-react-hook-form (last updated 2026-10-24)