The core library for managing forms with Preact Signals.
- TypeScript - Written in TypeScript with full type support for optimal DX.
- Reactivity - Reactivity without abstractions thanks to Preact Signals.
- Validation - Built-in validation support, including adapters for validation schema libraries.
- Transformations - Transform values for the specific needs of your input fields.
- Field Groups - Group fields together to manage parts of a form independently.
- Async Data - Easily manage async initialisation, validation and submission.
- Arrays + Dynamic Objects - Utilize arrays and dynamic objects within your forms.
npm install @formsignals/form-core
If you have not installed signals, you will need to install it as well:
npm install @preact/signals-core
Create a new form instance:
const form = new FormLogic({
defaultValues: {
name: '',
email: '',
},
});
Then get a field instance from the form and configure it:
const nameField = form.getOrCreateField('name', {
validate: (value) => {
if (!value) {
return 'Name is required';
}
},
});
Now you can interact with the field:
nameField.handleChange('John Smith');
You can also access the underlying signal directly:
const nameLength = computed(() => nameField.value.length);