What problem does it solve?
This Skill provides comprehensive guidance for building type-safe, validated forms in React using React Hook Form and Zod schemas. It covers client-side and server-side validation, dynamic form patterns, integration with shadcn/ui, and TypeScript type safety through Zod inference.
Core Features & Use Cases
- Complete React Hook Form API patterns: useForm, register, Controller, useFieldArray, useWatch, useController
- Zod Schema Patterns: all data types, refinements, transforms, error customization, nested objects
- shadcn/ui Integration: Form and Field component patterns
- Client + Server Validation: Single source of truth across client and server
- Advanced Patterns: Dynamic fields, multi-step forms, async validation, nested objects, arrays
- Error Handling & Accessibility: Accessible error display and ARIA attributes
- Type Safety & Performance: Type inference from Zod schemas and re-render optimization
Quick Start
- Define a Zod schema and infer its type with z.infer<typeof schema>.
- Initialize React Hook Form with the Zod resolver: useForm<{Data}>({ resolver: zodResolver(schema) }).
- Connect inputs with register or Controller and provide defaultValues to avoid uncontrolled-to-controlled warnings.
- Handle onSubmit with guaranteed-valid data and show validation messages.