Forms, testing & security · Design
Forms at scale: react-hook-form, zod and server validation
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voiceThe interviewer asks
Build a 30-field KYC form (PAN, Aadhaar, address, conditional GST fields) that stays fast and validates the same way on client and server. What's your approach?
Then
Follow-ups the interviewer asks next
- Why is react-hook-form faster than controlled
useStateper field? - Async validation (PAN already registered) with debounce.
- Multi-step wizard: where does state live, and how is it persisted on refresh?
- Accessibility of error messages.
The answer
What a strong answer covers
- Uncontrolled inputs with refs mean no re-render per keystroke.
zodResolvergives one schema, andz.infergives types. - Share the schema with the server (Server Action or API) and always re-validate on the server.
- Conditional fields via
watch/useWatchscoped to avoid wide re-renders.shouldUnregistersemantics. - Wizard state lives in the form context or URL step, with drafts in sessionStorage.
- a11y:
aria-invalid,aria-describedby, focus the first error, and don't rely on colour alone.
The red pen
Common traps
Avoid:validating only on the client; one giant useState object re-rendering everything.
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voicePractise questions like this out loud
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.