clipboard-listEngineering
Controlled vs uncontrolled inputs, React Hook Form, Zod schema validation, server actions, and error UX.
1 item
Controlled vs uncontrolled
value + onChange). Predictable, easy to react to every keystroke — but re-renders on every change.For anything beyond a trivial form, reach for React Hook Form — it minimizes re-renders, handles touched/dirty/error state, and integrates cleanly with schema validation.
Validate with a schema, share it everywhere
z.infer) — no duplicate type definitions,Client validation is UX; server validation is security
Server Actions for mutations
"use server" action can receive the form data, validate with Zod, perform the mutation, and revalidate the cache — no separate API route. Return field-level errors to drive the UI.useFormStatus / useActionState give pending and error state for a clean submit experience.Error & submission UX
aria-describedby and mark invalid fields aria-invalid (ties into the accessibility note).