useActionState
The useActionState hook connects a form to a server action and keeps the action's latest return value as state. The signup form below validates on the server: errors come back per field, submitted values are echoed so the form isn't wiped, and the built-in isPending flag drives the loading state — no useState bookkeeping required. It also works before JavaScript loads, since the form posts to the action natively.