Introduce the sicilian
react-hook-form, a widely used form state library in frontend development, operates around refs. That often requires wrapping components with forwardRef or using useFormContext. For many React developers, that constraint can be inconvenient.
sicilian addresses these issues by building on a global state approach. It manages each input as state and helps you write forms in a controlled-component style. Sicilian uses React's Context API internally to manage form state globally, so any component can access and manipulate form state without adding a separate global state library (e.g., Redux, Zustand).
What's new in sicilian@4.0.0#
- Replaced
registerwith the hook-styleuseRegisterusing a positional(name, options)signature. useFieldsnow returns field meta (touched,dirty,isValid) along with value and error.- Read access is unified through
useFields; there are nogetValues/getErrorshelpers. SicilianProvidercontext now usesuseRegisterand optionaluseFields.- Resolver imports are namespaced:
@ilokesto/sicilian/resolver/zod,/yup,/superstruct.
Installation#
sicilian can be installed using several methods listed below.
Quick start#
The example below shows basic sicilian usage. It implements a simple login form including validation for email and password fields. See how the sicilian form controller manages state and displays error messages for inputs.