Show server validation results
A server action validates submitted fields and returns errors.
Conform · Pipe
lastResult supplies useForm with the latest server submission result. Conform uses it to initialize and synchronize form state, including server-side validation feedback.
lastResult is the latest submission result returned by the server. Supplying it to useForm lets Conform use that result as the form's initial state, which supports progressive enhancement and surfaces server-side validation feedback.
useForm({ lastResult })| Name | Type | Description |
|---|---|---|
lastResult | SubmissionResult<ErrorShape> | null | The latest server-side submission result used for form-state synchronization and progressive enhancement. |
Not applicable: lastResult is an option rather than a standalone callable API.
import { useActionData } from "react-router";
import { useForm } from "@conform-to/react";
export default function Signup() {
const lastResult = useActionData<typeof action>();
const [form, fields] = useForm({ lastResult });
return (
<form id={form.id} method="post">
<input {...getInputProps(fields.email, { type: "email" })} />
<button type="submit">Sign up</button>
</form>
);
}Pass the server action's most recent submission result to useForm so Conform can synchronize the form with server validation state.
A server action validates submitted fields and returns errors.
A form must work with server validation before client enhancement is available.
A framework exposes the latest action state through a hook.
lastResult is an option passed to useForm. It represents the latest server submission result and lets Conform initialize or synchronize the form state with server-side validation.
Follow-up: How can a Remix form avoid a reset during loader revalidation? Pass the result only when navigation or fetcher state is idle; otherwise pass null.
The value normally comes from the framework's action-data mechanism, such as useActionData in Remix or useFormState in Next.js. The returned result is then supplied to useForm.
Follow-up: How does this support progressive enhancement? The server can validate and return the result even when client-side validation is absent or unavailable.
Conform uses the last submission result as the form's initial state for progressive enhancement. This allows server-returned errors and submission state to be reflected in the enhanced form.
Follow-up: What should be done when a loader supplies default values? Coordinate lastResult with the framework's idle state to prevent stale defaults from being applied.
useFormSubmissionResultuseActionDatauseFormStateform.status