Final Form is a high-performance, framework-agnostic library for managing form state in JavaScript applications. It provides a subscription-based model, meaning components only re-render when the specific pieces of state they subscribe to change, leading to optimized performance. The current stable version is 5.0.0, which notably converted the entire codebase from Flow to TypeScript, enhancing developer experience for TypeScript users. While core API stability is maintained across minor versions, major versions are bumped cautiously, as seen with v5.0.0, to reflect significant internal changes. Key differentiators include its zero-dependency footprint, small bundle size (around 5.1kB gzipped), and its explicit opt-in subscription model, giving developers fine-grained control over re-renders, making it suitable for complex form interactions across various UI frameworks.
npm install final-formVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a basic form instance with initial values, onSubmit and validation logic, and subscribe to form state changes using `createForm` from `final-form`.
Review TypeScript definitions in your project, especially if you had custom type augmentations for previous Flow-typed versions. Ensure your `tsconfig.json` is compatible and rebuild your application.
Always explicitly define which form state properties (e.g., `{ values: true, errors: true, dirty: true }`) your component needs to re-render. Avoid subscribing to `everything: true` unless absolutely necessary for debugging or specific scenarios.Ensure your async validation logic correctly returns promises and handles their resolution/rejection. Review the official documentation on `asyncValidate` and consider debouncing your validation function for better user experience and to prevent validation 'races'.
If using versions 4.20.7 or 4.20.8, explicitly handle `allValues` as potentially undefined or ensure your validator functions are robust to its presence. For optimal type safety, upgrade to >=4.20.9 where `allValues` is consistently required or check documentation for current behavior.
Ensure that the second argument to `form.subscribe` is a `FormSubscription` object, where keys are state properties and values are booleans indicating subscription interest, e.g., `{ values: true, errors: true }`.Use ES module import syntax: `import { createForm } from 'final-form';`. If in a CommonJS-only environment (e.g., older Node.js scripts), ensure your bundler or environment correctly transpiles ESM or use dynamic import if supported.Access form values via `formState.values.someField` and errors via `formState.errors.someField`. `FormState` itself contains metadata about the form, not the field values directly.
No dependency data recorded yet.