Version v3.0.0 Size 3.3 KB gzip
Why Forge?
Forge owns form state without owning rendering or validation timing. Nested field handles keep access typed, flat validation issues compose across arrays and unions, and Forge-owned validation and persistence operations settle on cancellation.
Quick Start
ts
import { createForm } from '@vielzeug/forge';
const form = createForm({
initialValues: { email: '', profile: { name: '' } },
validate: (values) =>
values.email.includes('@') ? undefined : [{ path: ['email'], message: 'Invalid email' }],
});
form.field('profile').field('name').set('Ada');
const result = await form.validate();| Feature | Forge | Local component state |
|---|---|---|
| Bundle size | 3.3 KB | n/a |
| Nested typed fields | Manual | |
| Flat validation issues | Manual | |
| Abortable validation | Manual | |
| Framework-neutral | Varies | |
| Zero third-party dependencies |
Use Forge when several fields need coordinated validation, submission, dirty/touched state, nested updates, or explicit persistence.
Use local state when a form has only one or two fields and no shared validation lifecycle.
Installation
sh
pnpm add @vielzeug/forgeFeatures
createForm()— deeply readonly form state with structural sharing and cloned datesfield().field()— typed nested field handles- Flat
{ path, message }validation issues - Explicit
validate()andsubmit()timing /dom— optional element binding/schema— validator-agnostic Standard Schema adapter/persist— explicit structural store integration/form-data— browser submission serialization