Tanstack + Zod + Shadcn UI
A comprehensive guide to building production-ready forms with validation
TanStack Form lets you control when validation happens. Try typing in each field to see the difference between modes.
Validates on every keystroke
Validates when you leave the field
Validates only when you click submit
Debounced validation with async checks
| Mode | When Validation Occurs | Best For |
|---|---|---|
| onChange | Every keystroke | Real-time feedback (e.g., password strength) |
| onBlur | When you leave the field | Less intrusive validation (recommended) |
| onSubmit | When form is submitted | Simple forms, minimal interruption |
| onChangeAsync | Debounced async checks | Availability checks, server-side validation |
The onBlur mode is recommended for most forms as it provides a good balance between user experience and validation feedback. Use onChange for fields that benefit from immediate feedback, like password strength indicators.
Built with Next.js 16, TanStack Form, Zod, and Shadcn UI