API Reference

SchemaForm API

Import from @verbb/plugin-kit-react/forms.

This is the canonical API reference for the schema engine itself.

Use this page when you need the exact hook, component, or engine-surface reference. For the conceptual setup flow, start in the SchemaForm guide section.

useSchemaFormEngine(options)

Returns a SchemaFormEngineApi instance.

Options

OptionTypeNotes
schemaIndexSchemaIndex | nullRequired when the form engine runs. Includes schema and fieldEntries.
defaultValuesRecord<string, unknown>Initial store values.
errorsvariousServer-side errors normalized to path -> string[].
onChange(values, form) => voidFires when store values change.
getConditionContext(values, field?) => Record<string, unknown>Extra condition scope for if.
parentFormSchemaFormEngineApi | nullRegisters a nested form when paired with parentPath.
parentPathstringPath under the parent store.

SchemaFormEngineApi

MemberPurpose
schemaNormalized renderable tree.
indexCompiled SchemaIndex with fieldEntries.
storeFormStateStore for values and errors.
FieldRender prop helper: form.Field name="path".
getFieldValue / setFieldValuePath-based accessors.
getErrorMapFieldsCurrent errors map.
getGroupedErrorsForPathAggregated messages for nested/complex fields.
handleSubmitValidate, merge nested errors, and invoke lifecycle handlers.
onSubmit / onError / onSuccess / onChangeRegister lifecycle handlers.
registerNestedForm / unregisterNestedFormNested form support.
SchemaRendererAdvanced internal renderer access.

SchemaFormEngine

tsx
<SchemaFormEngine form={form} className="space-y-4" />
<SchemaFormEngine form={form} withoutForm />
  • Forwards ref to the same SchemaFormEngineApi.
  • withoutForm renders a wrapper without creating a native <form>.

Schema node shape

Common schema keys include:

  • $field
  • $cmp
  • $el
  • name
  • label
  • validation
  • required
  • if
  • hideOnIf
  • children
  • schema
  • attrs
  • props

Example

tsx
import { SchemaFormEngine, useSchemaFormEngine } from '@verbb/plugin-kit-react/forms';

const form = useSchemaFormEngine({
  schemaIndex,
  defaultValues: initialData,
  errors: flashErrors,
});

form.onSubmit(async (values) => {
  await window.Craft.sendActionRequest('POST', 'my-plugin/save', {
    body: values,
  });
});

return <SchemaFormEngine form={form} />;

Internal vs public

The schema engine lives under src/forms/engine/, but not everything there is public API.

Treat these as implementation details unless you maintain the package itself:

  • FormStateStore
  • createValidationEngine
  • normalizeSchema
  • file-local internals such as SchemaProvider