void-form-pattern

Builds validated React forms with react-hook-form, Zod resolvers, and Server Action submit flows.

Updated May 29, 2026
One-click install
npx skills add https://github.com/voidcorp-core/void-harness --skill void-form-pattern-voidcorp-core
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: void-form-pattern
Source: https://github.com/voidcorp-core/void-harness/tree/main/packages/cli/core-assets/packs/pack-react/skills/void-form-pattern
Command: npx skills add https://github.com/voidcorp-core/void-harness --skill void-form-pattern-voidcorp-core

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires react-hook-form, @hookform/resolvers, zod.

What problem does it solve? Forms in React projects often end up with duplicated validation logic between client and server, inconsistent error UX, and ad-hoc state management. This Skill establishes a single default pattern—react-hook-form plus a shared Zod schema plus Server Actions—so validation lives in one place and error handling stays accessible. ## Core Features & Use Cases - Canonical form skeleton: Provides a complete react-hook-form + zodResolver component with field-level errors, role="alert" announcements, aria-invalid states, and submit-button disabling via formState.isSubmitting. - Shared schema discipline: Enforces one Zod schema imported by both the client form and the Server Action, eliminating client/server validation drift. - Boundary guidance: Documents when NOT to use a form library (single-field forms, file uploads, wizards) and lists anti-patterns like per-field useState and toast-based validation errors. - Use Case: When adding a contact or settings form to a Next.js app, the Skill generates the full component wired to a Server Action that re-validates with the same Zod schema server-side. ## Quick Start Ask the agent to build a contact form with email and message fields using react-hook-form, a shared Zod schema, and a Server Action submit handler.

Frequently Asked Questions about void-form-pattern

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a validated form with react-hook-form and Zod?

Define a Zod schema, pass it to useForm via zodResolver from @hookform/resolvers, register fields with form.register, and wrap your submit handler in form.handleSubmit. Render field errors inline with role="alert" for accessibility.

How do I share validation between client and server in Next.js?

Export one Zod schema from a shared module and import it in both the client form (via zodResolver) and the Server Action (via safeParse). Never duplicate the schema, since separate copies drift and let invalid data through.

When should I not use react-hook-form?

Skip it for single-field forms like search inputs or newsletter signups, where native HTML plus a Server Action suffices. File-upload-only forms also gain nothing from a form library, and complex wizards may fit a state machine better.

Why does my form lose values from multi-select or checkbox groups?

Object.fromEntries(formData) keeps only the last value of repeatable fields, silently dropping the rest. Read them with formData.getAll(name) in the Server Action and validate with z.array(...) in the shared schema.

Should I disable the submit button until the form is valid?

No. Disabling submit via !formState.isValid confuses users who cannot tell why the button is inactive. Let users click, then surface validation errors after the attempt; disable only during submission via formState.isSubmitting.