UNPKG

@bolttech/form-engine

Version:

A react adapter for bolttech form engine

26 lines (18 loc) 1.49 kB
# Changelog ## [3.1.0] - 2025-06-02 ### Features - **SSR support**: Form instances are now created synchronously during render via `useMemo`, allowing the component tree to produce meaningful HTML on the server - **`prefetchedData` prop**: Pass pre-fetched API data to `<Form />` so fields with API configurations have their response caches populated before mount - **`iVars` and `initialValues` at creation time**: These are now passed during form instance creation (not just in `useEffect`), making them available for the `FormCore` constructor during SSR - **Package metadata**: Added `"sideEffects": false` and `"exports"` field for proper tree-shaking and RSC compatibility - **Test infrastructure**: Added Jest configuration and SSR test suite (12 tests) ### How SSR works During server render, the `<Form />` component creates the `FormCore` instance synchronously in `useMemo`. Fields are registered when `AsFormFieldBuilder` mounts on the client via `useEffect`. Static props (non-template) render immediately; template props are stripped by `filterProps` and resolve after hydration when `refreshTemplates` runs. ### What renders during SSR | Content | SSR behavior | |---------|-------------| | Form structure (`<form>`) | ✅ Rendered | | Static props (label, placeholder) | ✅ Rendered | | Template props (`${iVars.*}`) | Stripped, resolved after hydration | | `visibility: false` fields | ✅ Correctly hidden | | Field interactivity | Activates after hydration |