A field-first form library for React and React Native.
Fielder is a form library for React and React Native that has been built from the ground up with a field-first approach to validation.
⚡️ Synchronous validation - no cascading renders
🛎 Validation events - validation can differ per event (change, blur, submit, etc.)
🪝 Hooks that work - hooks respond to validation changes
🧠 Evolving schemas - validation logic evolves with the UI
Add Fielder to your project.
npm i fielder
Use fielder
or fielder/preact
.
// React
import { useForm, ... } from 'fielder';
// Preact
import { useForm, ... } from 'fielder/preact';
Use the useForm
hook to create a form.
const myForm = useForm();
return <FielderProvider value={myForm}>{children}</FielderProvider>;
Use the useField
hook to create a field.
const [usernameProps, usernameMeta] = useField({
name: 'username',
initialValue: '',
validate: useCallback(({ value }) => {
if (!value) {
throw Error('Username is required!');
}
}, []),
});
return (
<>
<input type="text" {...usernameProps} />
<span>{usernameMeta.error}</span>
</>
);
Once you're all set up, be sure to check out the guides for a deeper dive!
For more info, tutorials and examples, visit the official docs site!
Also check out: