Identify native field elements
Rendering a standard text or checkbox control from useForm field metadata.
Conform · Pipe
field.key is the React key exposed by Conform field metadata. Assign it to the corresponding input element so React can track that field element correctly.
The field metadata exposes key as a value for React’s key prop. Applying fields.task.key to the input helps React identify the specific field element while the other metadata supplies its form attributes and state.
<input key={fields.fieldName.key} />import { useForm } from '@conform-to/react';
export function TaskForm() {
const [form, fields] = useForm({});
return (
<form id={form.id} method="post">
<input key={fields.task.key} name={fields.task.name} />
<button>Save</button>
</form>
);
}Use the field metadata key as the React key for the input so React can recreate that element when Conform changes the field identity.
Rendering a standard text or checkbox control from useForm field metadata.
Rendering repeated fields produced by a field list.
Combining metadata with manually selected accessibility and validation attributes.
Use fields.fieldName.key as the React key on the corresponding input. This lets React identify that field element independently from its name and other attributes.
Follow-up: Why not use the field name as the key? The metadata key represents the field’s current identity, while names can remain meaningful across state changes.
Place the value on the input’s key prop, for example <input key={fields.task.key} />. The official example applies the same pattern to regular inputs and checkboxes.
Follow-up: What other field metadata is commonly assigned to an input? Use id, name, formId, initialValue, validation state, constraints, and pattern-related properties as appropriate.
The key is part of field metadata, alongside properties such as id, name, and initialValue. The documentation shows it being used directly in JSX rather than generated through a separate API.
Follow-up: When would a helper be preferable? getInputProps can reduce repetitive attribute wiring for native input elements, while direct metadata is useful for custom control.
getInputPropsuseFormfield metadatagetFieldsetgetFieldList