PluginBench
Skill
Review
Audit score 70

react-hook-form

pproenca/dot-skills

Performance optimization guide for React Hook Form client-side forms with 45 rules across 8 categories.

What is react-hook-form?

Comprehensive reference for building optimized React Hook Form applications. Covers form configuration, field subscription, controlled components, validation, field arrays, state management, and integration patterns. Use this when developing client-side controlled forms with React Hook Form v7.55+.

  • Provides 45 prioritized rules for form configuration, field subscription, and controlled component patterns
  • Guides optimization of useForm, useWatch, useController, and useFieldArray for performance
  • Covers validation patterns, async submit handling, and server error integration
  • Includes integration patterns for Material-UI, shadcn, and Ant Design components
  • Offers field array best practices including virtualization and CRUD operation sequencing
  • Supplies state management strategies for form lifecycle and field-level state access

How to install react-hook-form

npx skills add https://github.com/pproenca/dot-skills --skill react-hook-form
Prerequisites
  • React Hook Form v7.55 or later
  • Basic familiarity with React hooks and form concepts
Claude Code
Cursor
Windsurf
Cline

How to use react-hook-form

  1. 1.Reference the rule categories table to identify relevant priority areas for your form
  2. 2.Read individual rule reference files matching your use case (e.g., formcfg-* for configuration)
  3. 3.Apply rules in priority order: Form Configuration and Field Subscription first (CRITICAL), then Controlled Components and Validation (HIGH)
  4. 4.Use code examples from reference files to implement patterns in your forms
  5. 5.Consult AGENTS.md for the complete expanded guide with all rules and examples

Use cases

Good for
  • Optimizing re-render performance in large multi-field forms with useWatch and subscribe()
  • Configuring form validation mode and revalidation strategy for expensive async validators
  • Integrating controlled UI library components (MUI, shadcn) with useController
  • Managing dynamic field arrays with proper keying and default value handling
  • Handling server-side validation errors and async submit state management
Who it's for
  • React developers building client-side forms with React Hook Form
  • Frontend engineers optimizing form performance and re-render behavior
  • Teams integrating third-party UI component libraries with form validation
  • Developers handling complex form state and async validation workflows

react-hook-form FAQ

When should I use React Hook Form vs. uncontrolled forms?

Use React Hook Form for multi-field forms with validation, dynamic fields, or complex state. For single-input or trivial forms, uncontrolled `<form>` + `FormData` is often simpler.

Does this skill cover React 19 Server Actions?

No. This skill focuses on client-side form handling. For React 19 Server Actions and useActionState, use the react-19 skill instead.

What's the difference between watch() and useWatch()?

useWatch is preferred for isolated re-renders of specific fields. Use watch() only for one-time reads in render. For side-effects, use subscribe() instead.

How do I handle server validation errors?

Surface server errors via setError('root.serverError', ...) and access them through formState.errors.root.serverError.

Should I use TanStack Form instead of React Hook Form?

This skill assumes you've chosen React Hook Form. TanStack Form may be better for deeply nested, fully type-safe forms with complex schemas.

Full instructions (SKILL.md)

Source of truth, from pproenca/dot-skills.


name: react-hook-form description: React Hook Form performance optimization for client-side form validation using useForm, useWatch, useController, useFieldArray, and the v7.55+ subscribe() API. This skill should be used when building client-side controlled forms with React Hook Form library. This skill does NOT cover React 19 Server Actions, useActionState, or server-side form handling (use react-19 skill for those).

React Hook Form Best Practices by Community

Comprehensive performance optimization guide for React Hook Form applications. Contains 45 rules across 8 categories, prioritized by impact to guide form development, automated refactoring, and code generation.

When to Apply

Reference these guidelines when:

  • Writing new forms with React Hook Form
  • Configuring useForm options (mode, defaultValues, validation)
  • Subscribing to form values with watch / useWatch / subscribe
  • Integrating controlled UI components (MUI, shadcn, Ant Design)
  • Managing dynamic field arrays with useFieldArray
  • Handling async submit, server errors, and submit lifecycle state
  • Reviewing forms for performance issues

When NOT to Use This Skill

  • React 19 Server Actions / useActionState — use the react-19 skill instead
  • Deeply nested, fully type-safe forms — TanStack Form may be a better fit for forms with complex nested schemas; this skill assumes you've already chosen RHF
  • Single-input or trivial forms — uncontrolled <form> + FormData is often simpler than pulling in any library

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Form ConfigurationCRITICALformcfg-
2Field SubscriptionCRITICALsub-
3Controlled ComponentsHIGHctrl-
4Validation PatternsHIGHvalid-
5Field ArraysMEDIUM-HIGHarray-
6State ManagementMEDIUMformstate-
7Integration PatternsMEDIUMinteg-
8Advanced PatternsLOWadv-

Quick Reference

1. Form Configuration (CRITICAL)

  • formcfg-validation-mode - Use onSubmit mode for optimal performance
  • formcfg-revalidate-mode - Consider reValidateMode for expensive validation
  • formcfg-default-values - Always provide defaultValues for form initialization
  • formcfg-async-default-values - Use async defaultValues for server data
  • formcfg-should-unregister - Enable shouldUnregister for dynamic form memory efficiency
  • formcfg-useeffect-dependency - Avoid useForm return object in useEffect dependencies
  • formcfg-disabled-prop - Understand that register's disabled prop clears the value

2. Field Subscription (CRITICAL)

  • sub-usewatch-over-watch - Use useWatch instead of watch for isolated re-renders
  • sub-watch-specific-fields - Watch specific fields instead of entire form
  • sub-subscribe-outside-react - Use subscribe() for non-UI side-effects (analytics, autosave)
  • sub-usewatch-with-getvalues - Combine useWatch with getValues for timing safety
  • sub-deep-subscription - Subscribe deep in component tree where data is needed
  • sub-avoid-watch-in-render - Avoid calling watch() in render for one-time reads
  • sub-usewatch-default-value - Provide defaultValue to useWatch for initial render
  • sub-useformcontext-sparingly - Use useFormContext sparingly for deep nesting

3. Controlled Components (HIGH)

  • ctrl-usecontroller-isolation - Isolate controlled inputs in dedicated child components
  • ctrl-avoid-double-registration - Avoid double registration with useController
  • ctrl-controller-field-props - Wire Controller field props correctly for UI libraries
  • ctrl-single-usecontroller-per-component - Use single useController per component
  • ctrl-local-state-combination - Combine local state with useController for UI-only state

4. Validation Patterns (HIGH)

  • valid-resolver-caching - Define schema outside component for resolver caching
  • valid-server-errors - Surface server errors via setError('root.serverError', ...)
  • valid-dynamic-schema-factory - Use schema factory for dynamic validation
  • valid-error-message-strategy - Access errors via optional chaining or lodash get
  • valid-inline-vs-resolver - Prefer resolver over inline validation for complex rules
  • valid-delay-error - Use delayError to debounce rapid error display
  • valid-native-validation - Consider native validation for simple forms

5. Field Arrays (MEDIUM-HIGH)

  • array-use-field-id-as-key - Use field.id as key in useFieldArray maps
  • array-complete-default-objects - Provide complete default objects for field array operations
  • array-separate-crud-operations - Separate sequential field array operations
  • array-unique-fieldarray-per-name - Use single useFieldArray instance per field name
  • array-virtualization-formprovider - Use FormProvider for virtualized field arrays

6. State Management (MEDIUM)

  • formstate-async-submit-lifecycle - Wrap async submit handlers in try/catch and reset on isSubmitSuccessful
  • formstate-destructure-formstate - Destructure formState properties before render
  • formstate-useformstate-isolation - Use useFormState for isolated state subscriptions
  • formstate-getfieldstate-for-single-field - Use getFieldState for single field state access
  • formstate-subscribe-to-specific-fields - Subscribe to specific field names in useFormState
  • formstate-avoid-isvalid-with-onsubmit - Avoid isValid with onSubmit mode for button state

7. Integration Patterns (MEDIUM)

  • integ-shadcn-form-import - Verify shadcn Form component import source
  • integ-shadcn-select-wiring - Wire shadcn Select with onValueChange instead of spread
  • integ-mui-controller-pattern - Use Controller for Material-UI components
  • integ-value-transform - Transform values at Controller level for type coercion

8. Advanced Patterns (LOW)

  • adv-formprovider-memo - Wrap FormProvider children with React.memo
  • adv-devtools-performance - Disable DevTools in production and during performance testing
  • adv-testing-wrapper - Create test wrapper with QueryClient and AuthProvider

How to Use

Read individual reference files for detailed explanations and code examples:

Related Skills

  • For schema validation with Zod resolver, see zod skill
  • For React 19 server actions, see react-19 skill
  • For UI/UX form design, see frontend-design skill

Full Compiled Document

For the complete guide with all rules expanded: AGENTS.md

Related skills

More from pproenca/dot-skills and the wider catalog.

zod logo

zod

pproenca/dot-skills

Zod schema validation best practices for type safety, parsing, and error handling.

3.8k installsAudited
emilkowal-animations logo

emilkowal-animations

pproenca/dot-skills

Emil Kowalski's animation best practices for React, CSS, and Framer Motion.

1.8k installs
clean-architecture logo

clean-architecture

pproenca/dot-skills

Clean Architecture principles and best practices for designing maintainable, testable software systems.

1.7k installs
vitest logo

vitest

pproenca/dot-skills

Vitest testing framework patterns for test setup, async testing, mocking with vi.*, snapshots, and test performance (formerly test-vitest). This skill should be used when writing or debugging Vitest tests. This skill does NOT cover TDD methodology (use test-tdd skill), API mocking with MSW (use test-msw skill), or Jest-specific APIs.

1.1k installsAudited
nuqs logo

nuqs

pproenca/dot-skills

nuqs (type-safe URL query state) best practices for Next.js and other React frameworks. This skill should be used when writing, reviewing, or refactoring code that uses nuqs for URL state management. Triggers on tasks involving useQueryState, useQueryStates, search params, URL state, query parameters, nuqs parsers, limitUrlUpdates, Standard Schema, NuqsAdapter, or Next.js routing with state.

1.1k installsAudited
code-simplifier logo

code-simplifier

pproenca/dot-skills

Code simplification skill for improving clarity, consistency, and maintainability while preserving exact behavior. Use when simplifying code, reducing complexity, cleaning up recent changes, applying refactoring patterns, or improving readability. Triggers on tasks involving code cleanup, simplification, refactoring, or readability improvements.

1.0k installs