# @xvii/useform

> Forms for ReactJS.

Latest version **0.3.3** (published 2026-06-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @xvii/useform
pnpm add @xvii/useform
yarn add @xvii/useform
bun add @xvii/useform
```

## Health

**Score 55/100 (C)** — status: active.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.3.3 |
| Published | 2026-06-24 |
| First published | 2023-02-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 46.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Avezov |
| Maintainers | xvii |
| Keywords | react, hook, form |

## Links

- npm: https://www.npmjs.com/package/@xvii/useform
- Repository: https://github.com/avezov/useForm
- Homepage: https://github.com/avezov/useForm#readme
- Issues: https://github.com/avezov/useForm/issues
- npm.io page: https://npm.io/package/@xvii/useform

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^4.17.21

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.3.3 (latest) — 2026-06-24
- 0.3.2 — 2026-04-17
- 0.3.1 — 2024-12-05
- 0.3.0 — 2024-12-05
- 0.2.6 — 2024-11-26
- 0.2.5 — 2024-02-21
- 0.2.4 — 2024-02-20
- 0.2.3 — 2024-02-20
- 0.2.2 — 2024-02-20
- 0.2.1 — 2024-02-20
- 0.2.0 — 2024-02-20
- 0.1.29 — 2024-02-20
- 0.1.28 — 2024-01-10
- 0.1.27 — 2024-01-10
- 0.1.26 — 2024-01-10
- … 25 more at https://npm.io/package/@xvii/useform/versions

## README

# @xvii/useForm

Forms for ReactJS.

# Installation

```bash
npm install --save @xvii/useform
```

# Example

```js
import { useForm } from '@xvii/useform';

const form = useForm({
  onSubmit(formData) {
    console.log("Submit", formData);
  },
  fields: {
    login: {
      valueType: String(),
      validators: [
        notEmpty({ errorText: "Login cannot be empty" }),
        minLength({
          errorText: "The login must be longer than 3 characters.",
          minLength: 3,
        }),
      ],
      validateOnChange: true
    },
    password: {
      defaultValue: "",
      validators: [notEmpty({ errorText: "Password cannot be empty" })],
    },
    remember: {
      defaultValue: false,
      valueType: Boolean(),
    },
  },
});
```

```jsx
<TextField
  label="Login"
  error={form.fields.login?.error}
  helperText={form.fields.login?.errorText}
  onChange={form.fields.login?.handleChange}
  value={form.fields.login?.value}
/>

<Checkbox
  checked={form.fields.remember?.value}
  onChange={form.fields.remember?.toggle}
/>
```

# Form

| Property | Type | Description |
| --- | --- | --- |
| fields | FormField | List of form fields |
| getFormData | () => data | Returns an object with values of all fields |
| handleSubmit | () => boolean | Handler function for submitting the form |
| isValid | boolean | The current validity status of all fields |
| setFormData | (data) => void | Sets the values of the form fields |
| validate | () => void | Force validation of all fields |


# FormField

| Property | Type | Description |
| --- | --- | --- |
| error | boolean | Validation error state |
| errorText | string | Description of error |
| handleChange | (evt) => void | Handler for `onChange` |
| pushToArray | (value) => void | Add value for arrayable fields |
| removeFromArray | (value) => void | Remove value from arrayable fields |
| replaceValidators | () => void | Replace validators for current field |
| setValue | (value) => void | Set value of field |
| toggle | () => void | Toggler for boolean values |
| validate | () => void | Force validation of field |
| value | | Value of field |

---
_Source: https://npm.io/package/@xvii/useform · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
