Prepopulate fields from stored data
Editing an existing record
Conform · Type Alias
DefaultValue is the type used for initial Conform form data. It accepts a partial object matching the form shape or a URLSearchParams object.
DefaultValue describes the initial values accepted by Conform's form APIs. It can represent a partial object matching the form structure, allowing only some fields to be initialized, and it is also used alongside URLSearchParams for form initialization.
defaultValue?: DefaultValue<FormShape> | URLSearchParams| Name | Type | Description |
|---|---|---|
defaultValue | DefaultValue<FormShape> | URLSearchParams | Optional initial data for the form, represented by a partial object matching the form structure or URLSearchParams. |
const defaultValue: DefaultValue<{ email: string }> = {
email: 'user@example.com',
};
const [form] = useForm({ defaultValue });Pass a partial form-shaped object as the initial value when creating a form.
Editing an existing record
Progressive form initialization
Partial drafts
DefaultValue represents initial form data supplied to Conform. For useForm, the documented input can be a partial object matching the form structure or a URLSearchParams object.
Follow-up: Why might a partial object be useful? It lets callers initialize only the fields for which values are available, leaving other fields uninitialized.
It is passed through the form setup option named defaultValue. The value establishes the form's initial state rather than describing the current live state after editing.
Follow-up: Where can the current form state be read? Use the form metadata returned by Conform, which distinguishes initial values from the current value.
A default can be provided as URLSearchParams when initialization data already uses URL-encoded form semantics. Otherwise, use an object whose shape corresponds to the form.
Follow-up: What should be checked when choosing the object form? Ensure its keys and nested structure correspond to the form schema expected by Conform.
useFormFormShapeURLSearchParamsinitialValuevalue