@formzk/core
Headless form library. You get three building blocks:
- A Provider that registers reusable input components by name.
- A Form wrapper that creates a
react-hook-formcontext. - An Input component that resolves
component="..."against the registry and wiresController.
See the full API reference.
import { Formzk, FormzkProvider } from '@formzk/core';
import { MyTextField } from './components';
const config = [
{ name: 'MyTextField', component: MyTextField },
];
export function App({ children }) {
return <FormzkProvider config={config}>{children}</FormzkProvider>;
}
When to use
- You want one form declaration to render across MUI today and Tamagui/whatever tomorrow.
- You want the ergonomics of react-hook-form's
Controllerwithout writing it for every field. - You want typed
componentnames via TypeScript declaration merging.
When not to use
- You only have one input component and no adapter story — react-hook-form alone is simpler.
- You need uncontrolled inputs —
Formzk.Inputalways goes throughController(controlled).
Concepts
- ComponentPropsMap — an augmentable interface that maps
component="Xxx"strings to their prop types. Augment it from the consumer app for full autocomplete. - ComponentPropsOf<K> — internal helper that falls back to
anywhen the consumer hasn't augmented the map, so JSX usage doesn't break. - ComponentName — helper that resolves to
keyof ComponentPropsMapwhen augmented, orstringwhen empty — used on APIs likegetComponent.
See the API reference and how to register components.