Workers and performance
Engine execution
The default engineMode="main-thread" evaluates the form engine on the UI thread. Use
engineMode="worker" to move engine evaluation into the packaged module worker when Web Workers
are available:
Code
Vite supports the static module-worker pattern used by the package and emits the worker during a
production build. The maintained Vite starter excludes form0-react from dependency optimization
so this worker remains available.
The public FormRenderer API does not accept a custom worker URL or worker factory. Applications
using another bundler should confirm that it supports
new Worker(new URL("./worker.js", import.meta.url), { type: "module" }); otherwise use the default
main-thread mode.
If the browser has no Worker support, the binding falls back to main-thread execution.
React store mode
engineStoreMode="snapshot" clones the engine snapshot into React state and is the default.
engineStoreMode="selector" uses field subscriptions to reduce broad rerenders.
Treat selector mode as an optimization: verify field errors, navigation summaries, repeatable sections, and submission behavior in the target application before adopting it.
Engine options in worker mode
Application callbacks (onDiagnostics, onWarning, onUpdate, onOperations) stay on the host; they are not serialized into the worker. Schema, values and engine configuration must be structured-cloneable. Function-valued helpers and other non-cloneable configuration are rejected with a clear initialization error before a request is dispatched: use engineMode="main-thread" for function helpers. Configuration failure does not silently change the requested mode or drop helpers. Diagnostic messages are accepted once per active scope/evaluation; obsolete generations cannot restore old findings. See FormRenderer for the shared interface.
If replacing the schema or initial seed while a worker is still initializing, remount FormRenderer to initialize the replacement predictably. Obsolete diagnostic scopes end immediately, but reporting does not schedule an extra evaluation. An empty active diagnostic collection does not establish that the replacement has evaluated.
Managed events and custom validation
Managed event requests/results are cloneable data. Callbacks and alerts stay on the host; each reply is consumed once and obsolete generations are rejected. Promise completion waits for operation delegation and default worker updates. Function-valued helpers remain unsupported in worker mode; use main-thread execution. No additional evaluation is added by validation or lifecycle notifications.