Preserve reload state
A progressively enhanced form must retain Conform state after a document reload.
Conform · Component
FormStateInput renders a hidden input that preserves Conform form state across document reloads. Use it inside FormProvider when full progressive enhancement must retain validation errors and other state.
FormStateInput is a React component that renders a hidden input for preserving Conform form state during a document reload. Render it inside FormProvider with the form context when progressive enhancement requires errors and other state to survive reloads.
<FormStateInput />A React element containing a hidden input that persists form state.
import { FormProvider, FormStateInput, useForm } from '@conform-to/react';
export default function SomeParent() {
const [form] = useForm();
return (
<FormProvider context={form.context}>
<form method="post">
<FormStateInput />
<input name="email" type="email" />
<button type="submit">Save</button>
</form>
</FormProvider>
);
}Place the component inside a FormProvider so it can persist and restore Conform's form state across document reloads.
A progressively enhanced form must retain Conform state after a document reload.
A non-submit intent changes form structure and should keep existing validation errors visible.
A form uses FormProvider and needs the documented state-persistence integration.
FormStateInput renders a hidden input that persists Conform's form state when the document reloads. It should be rendered within FormProvider and does not require configuration props.
Follow-up: When is it especially useful? It is useful for full progressive enhancement, particularly when a non-submit intent reloads the document and previously validated errors must remain visible.
The component consumes the context supplied by FormProvider, so the usual pattern is to pass form.context to FormProvider and render FormStateInput inside it. The component itself accepts no props.
Follow-up: What happens if it is rendered outside the provider? The documented usage requires the provider context; therefore it cannot obtain the form state through the intended integration pattern.
It is optional when reload persistence is unnecessary. Use it when aiming for full progressive enhancement, because it lets Conform restore state and keep errors from all validated fields displayed after a reload.
Follow-up: Why can a normal submission differ from a non-submit intent? A non-submit intent, such as inserting a field into a list, can reload the document without preserving the same validated-field error information unless the state input is present.
FormProvideruseForm