Forms and Validation
Build robust forms with clear validation behavior and minimal duplication.
Recommended approach
- Use React Hook Form for form state.
- Use schema validators (Zod or Typebox) for input parsing and validation.
- Keep client validation user-friendly and server validation authoritative.
Alternatives and when to choose them
- Native form handling for very small forms.
Implementation checklist
- Define field-level and form-level validation messages.
- Handle async submission errors consistently.
- Normalize server validation errors into field messages.
Common pitfalls
- Trusting client-only validation for security-sensitive flows.
- Splitting validation rules inconsistently between client and server.