RHF + server submit flow
Integration Layer
- •Single hook for React Hook Form and server submit handlers
- •Schema-driven types from withZod into client usage
- •Automatic data and error shape handling for common server responses
Connect React Hook Form to Server Actions or submit functions with end-to-end types, Zod mapping, optimistic UI, and persistence for multi-step flows.
Pick your adapter. Keep one API. Ship production forms faster.
From install to first submit in around two minutes.
Step 1
Step 2
export const action = withZod(schema, async (data) => {
return { success: true };
});Step 3
const form = useActionForm(action, {
validationMode: 'onChange',
});
<form onSubmit={form.handleSubmit()} />Same primitives, less glue code. You keep RHF and Zod control, but remove repeated submit-flow plumbing.
| Concern | Manual | hookform-action |
|---|---|---|
| Type safety from schema to submit handler | Manual casting and duplicated generic types | Inference from withZod schema to useActionForm |
| Server validation errors to RHF fields | Parse fieldErrors and loop setError() per field | Automatic mapping through default error mapper |
| Pending submit state | Wire useTransition separately from RHF formState | formState.isPending available in the hook result |
| Optimistic UI with rollback | Build custom useOptimistic wiring per form | Enable optimisticData and optimisticKey options |
| Multi-step persistence | Custom sessionStorage effects and debounce logic | Built-in persistKey and persistDebounce options |
| Cross-framework submit flow | Rewrite integration for each stack | Same API in Next.js and standalone adapters |
Before (manual)
const result = await action(values);
if (result.errors) {
for (const [field, messages] of Object.entries(result.errors)) {
setError(field as keyof Fields, { message: messages[0] });
}
}After (hookform-action)
const { handleSubmit, formState: { errors, isPending } } =
useActionForm(action, { validationMode: 'onChange' });
<form onSubmit={handleSubmit()} />;-1 layer
single integration API for submit flows
+1 schema
server and client stay aligned
-N bugs
less custom wiring to maintain per form
Built on top of RHF. No lock-in, only less repetition.
RHF + server submit flow
Fast forms without custom plumbing
Fits existing architecture
Built for real projects
Use these as your onboarding path: beginner to advanced submit flows.
Typed login form with field-level server validation and pending button state.
Open login example →Immediate UI updates during submit, with rollback behavior when server fails.
Open optimistic example →Persist form progress across reloads and steps with a shared persist key.
Open wizard example →Same API using submit functions with fetch, axios, or RPC endpoints.
Open standalone recipe →One schema, one action, one form hook.
withZod.useActionForm.handleSubmit().withZod(schema, handler)
|
v
useActionFormCore
/ \
v v
hookform-action hookform-action-standalone
\ /
v v
hookform-action-devtools| Dependency | Minimum | Notes |
|---|---|---|
| React | 18.0+ | React 19 recommended for native useOptimistic behavior. |
| React Hook Form | 7.50+ | Required peer dependency. |
| Zod | 3.22+ | Optional, recommended for withZod and typed validation flow. |
| Next.js | 14.0+ | Only required for the Next.js adapter package. |
Current package line is 4.0.x. Before upgrading, check package changelogs to confirm API notes and migration details for your adapter.
Production-focused signals to reduce adoption risk.
v4.0.x adapters and core published independently.
Open source license with permissive commercial usage.
Core and standalone packages include Vitest test suites.
Repository checks run in public workflow pipelines.
Each package has explicit release notes and history.
Changesets + release process managed in monorepo scripts.
No. You still use RHF primitives directly. The library removes repeated glue code between RHF, server submit handlers, and schema validation.
If your form never hits a server, native RHF is often enough. The value appears when multiple forms share server submit and validation flows.
Yes. Use hookform-action-standalone for Vite, Remix, Astro, or any React app with async submit functions.
Zod is optional, but recommended. withZod unlocks end-to-end type inference and automatic error mapping without duplicated schema setup.
Start with the adapter that matches your stack and move from setup to running form quickly.