---
url: https://formhaus.dev/migrate/0.22.md
description: >-
  Upgrade from Formhaus 0.21 to 0.22: removed deprecated APIs, options objects,
  React and Vue names, issue codes, the error summary and drafts on by default.
---

# Migrate to 0.22

0.22 is the last breaking release before 1.0. The definition format stays 1.5: definitions and submissions do not change.

```bash
npm i @formhaus/core@^0.22 @formhaus/react@^0.22
npm i @formhaus/core@^0.22 @formhaus/vue@^0.22
```

## Changes

### Core

| Old (0.21) | New (0.22) | Action |
|---|---|---|
| `validateDefinition` | Removed | Use `checkDefinition(input).map((issue) => issue.message)` |
| `FormAnalyticsEvent` | Removed | Use `FormEvent` |
| `SubmitFn` | `AfterSubmitFn` | Rename the type |
| `ValidationRule` | Removed | Use `MessageKey`. `getDefaultMessage()` takes a `MessageKey` |
| `parseDefinition(input, options)` | `parseDefinition(input)` | Drop the second argument |
| `validateFieldValue(field, value, values, validators, messages)` | `validateFieldValue(field, value, values, { validators, messages })` | Pass an options object |
| `validateFields(nodes, values, validators, messages)` | `validateFields(nodes, values, { validators, messages })` | Pass an options object |
| `validateStep(step, values, validators, messages)` | `validateStep(step, values, { validators, messages })` | Pass an options object |
| `form_submit_failed` fired only after `form_submitted` | It also fires with `reason: 'validation'` when Submit fails client validation. A thrown error adds its numeric `status` | Count only `reason: 'rejected'` and `'error'` if a report needs the old numbers |

### Issue codes

| Old (0.21) | New (0.22) | Action |
|---|---|---|
| `invalid-range` for `min` above `max` or `minLength` above `maxLength` | `min-greater-than-max` | Rename in code that matches issue codes |
| `invalid-range` for `defaultItems` above `maxLength` | `default-items-greater-than-max` | Rename |
| `invalid-range` warning for a group over its item limit | `group-item-limit` | Rename |
| `invalid-range` for `columns` outside 1 to 4 | `invalid-columns` | Rename |
| `empty-label`, and `missing-property` for a `label` at the path of its object | `missing-label` at the path of the `label`, such as `/fields/0/label` | Rename, and match the new path |
| `i18n-unbound-slot` | `i18n-key-without-text` | Rename |

### Cloud client

| Old (0.21) | New (0.22) | Action |
|---|---|---|
| `fetchForm(options, signal, after)` | `fetchForm({ ...options, signal, version })` | Pass an options object |
| `fetchDefinition` | Removed | Use `(await fetchForm(options)).definition` |
| `createSubmitter(options)` returned `submit(values, skippedSteps, challengeToken)` | `submit(values, { skippedSteps, challengeToken })` | Pass an options object |
| `createChallengeFrame(challenge, formId, host, timeout, quiet)` | `createChallengeFrame({ challenge, formId, host, timeout, quiet })` | Pass an options object |
| `sessionDraftStore(maxAge, storage)` | `sessionDraftStore({ maxAge, storage })` | Pass an options object |
| `new CloudError(status, code, errors, version, cause)` | `new CloudError({ status, code, errors, version, cause })` | Pass an options object |

```ts
const form = await fetchForm({ id: 'FORM_ID', signal });
const submit = createSubmitter({ id: 'FORM_ID', version: form.version, renderToken: form.renderToken });
const check = form.challenge && createChallengeFrame({ challenge: form.challenge, formId: 'FORM_ID', host: () => box });
await submit(values, { skippedSteps: [], challengeToken: await check?.token() });
```

### React

| Old (0.21) | New (0.22) | Action |
|---|---|---|
| `onAnalyticsEvent` | Removed | Use `onFormEvent` |
| `onPrev` in `FormActionsProps` | `onBack` | Rename in a custom actions component |
| `ItemComponent` in `GroupComponentProps` | `itemComponent` | Rename in a custom group component |
| `useLocalizedForm(definition, source, deps)` | `useLocalizedForm(definition, source, { key })`. A new `translate` function does not rebuild the form. The definition, `lang`, `prefix`, the overlay or `key` do | Replace `deps` with `{ key }`, such as `{ key: t }` with react-i18next |

```tsx
function Group({ items, itemComponent: Item }: GroupComponentProps) {
  return items.map((item) => <Item key={item.id} {...item} />);
}

const form = useLocalizedForm(
  definition,
  { translate: (key, params, defaultValue) => t(key, { ...params, defaultValue }), lang: i18n.language },
  { key: t },
);
```

### Vue

| Old (0.21) | New (0.22) | Action |
|---|---|---|
| `submitHandler` | Removed | Use `@submit` |
| `@analytics-event` | Removed | Use `@form-event` |
| `FormFieldProps` | `FieldComponentProps` | Rename the type |
| `formFieldProps`, `formFieldEmits` | `fieldComponentProps`, `fieldComponentEmits` | Rename the imports |
| `prev` emit of a custom actions component | `back` | Emit `back` |

```vue
<script setup lang="ts">
import { fieldComponentEmits, fieldComponentProps } from '@formhaus/vue';
const props = defineProps(fieldComponentProps);
const emit = defineEmits(fieldComponentEmits);
</script>
```

### React and Vue

| Old (0.21) | New (0.22) | Action |
|---|---|---|
| `errorSummary` was off by default | The error summary shows by default | Pass `errorSummary={false}` or `:error-summary="false"` to hide it |
| `draftStore` was off by default in `FormhausForm` | `FormhausForm` keeps a draft in `sessionStorage` without `password`, `file` and `hidden` values | Pass `draftStore={false}` to turn drafts off, or `draftExclude` with the keys of sensitive fields. See [Drafts](/guide/endpoint#drafts) |
| After a failed Continue or Submit, focus moved to the first invalid field | With two or more errors, focus moves to the error summary. With one error, or with `errorSummary` off, focus moves to the invalid field | Update tests that expect the first field to have focus |

### Vue FormhausForm

| Old (0.21) | New (0.22) | Action |
|---|---|---|
| `FormhausForm` removed a group item with answers without asking | It asks first, like `FormRenderer` | Pass `:confirm-remove="false"` to remove without asking |

### Styles

The private custom properties of `style.css` start with `--fhi-`. Only the variables listed in [Optional baseline styles](/guide/#optional-baseline-styles) are public.

| Old (0.21) | New (0.22) | Action |
|---|---|---|
| `--fh-auto-*`, such as `--fh-auto-input-padding` | `--fhi-auto-*` | Set the public variable instead, such as `--fh-input-padding` |
| `--fh-x`, `--fh-check`, `--fh-plus`, `--fh-zoom`, `--fh-star`, `--fh-star-fill`, `--fh-mask` | `--fhi-x`, `--fhi-check`, `--fhi-plus`, `--fhi-zoom`, `--fhi-star`, `--fhi-star-fill`, `--fhi-mask` | Rename in CSS that reads the icons |
| `--fh-columns`, `--fh-matrix-columns`, `--fh-matrix-label`, `--fh-matrix-row`, `--fh-scale-points` | `--fhi-columns`, `--fhi-matrix-columns`, `--fhi-matrix-label`, `--fhi-matrix-row`, `--fhi-scale-points` | Rename in custom components that set them |

### Native ports

The conformance files in `packages/core/fixtures/conformance` use the new issue codes. `scenarios/lifecycle.json`, `scenarios/recall-identifiers.json` and `scenarios/skip-steps.json` expect `form_submit_failed` with `reason: 'validation'` before `field_error`. `scenarios/go-to-step.json` covers the new `goToStep()`.
