Motivation
Most web frameworks do not offer a comprehensive solution for form handling, leaving developers to create their own custom implementations or rely on less-capable libraries. This often results in a lack of consistency, poor performance, and increased development time. TanStack Form aims to address these challenges by providing an all-in-one solution for managing forms that is both powerful and easy to use. With TanStack Form, developers can tackle common form-related challenges such as:- Reactive data binding and state management - Keep your form state in sync with your UI effortlessly
- Complex validation and error handling - Support for sync/async validation with flexible timing
- Accessibility and responsive design - Build forms that work for everyone
- Internationalization and localization - Easy integration with i18n solutions
- Cross-platform compatibility and custom styling - Works with any framework and design system
Framework-Agnostic Architecture
TanStack Form is built on a framework-agnostic core (@tanstack/form-core) that provides all the state management and validation logic. Framework-specific adapters then provide bindings for:
- React -
@tanstack/react-form - Vue -
@tanstack/vue-form - Angular -
@tanstack/angular-form - Solid -
@tanstack/solid-form - Svelte -
@tanstack/svelte-form - Lit -
@tanstack/lit-form
The framework-agnostic core means you can learn TanStack Form once and use it anywhere. The concepts and patterns remain the same regardless of your framework choice.
Core Concepts
Form State Management
At the heart of TanStack Form is theFormApi class, which manages:
- Field values - The current data in your form
- Field metadata - Touched, dirty, validating states
- Validation errors - Per-field and form-level errors
- Submission state - Loading, success, and error states
Field-Level Control
Fields are registered using theField component or API, which provides:
- Type-safe field names - Autocomplete and validation for field paths
- Independent validation - Each field can have its own validation logic
- Granular re-rendering - Only affected fields re-render on changes
Validation Flexibility
TanStack Form supports multiple validation strategies:- Timing customizations - Validate on blur, change, submit, or mount
- Synchronous validation - Immediate validation with instant feedback
- Asynchronous validation - Server-side validation with debouncing and cancellation
- Custom validation logic - Write your own validators or use libraries like Zod or Valibot
- Form-level validation - Validate across multiple fields
Controlled Inputs
TanStack Form uses controlled inputs by default, which provides:- Predictable state - Always know the current form state
- Easier testing - Test forms by passing values and asserting outputs
- Non-DOM support - Works with React Native, Three.js, and other renderers
- Enhanced conditional logic - Show/hide fields based on form state
- Better debugging - Log form state to debug issues
Key Features
Type-Safe Field Access
TanStack Form provides full TypeScript support with deep type inference for nested objects and arrays:Array and Nested Fields
Manipulate array fields with built-in utilities:Subscriptions for Performance
Subscribe to specific parts of form state to optimize re-renders:Using
form.Subscribe with a selector allows you to only re-render when specific parts of the form state change, improving performance in complex forms.Getting Started
Ready to build powerful forms? Check out the Installation Guide to get started, or explore the API Reference for detailed documentation.Next Steps
- Learn about the Design Philosophy behind TanStack Form
- Explore TypeScript support and type inference
- Follow the Quick Start Guide to build your first form