gform-react

Features

Performant, type-safe React forms that work the same on the web, with native and Next.js Server Actions, and in React Native - no adapters, no casts, zero dependencies.

Lightweight & fast

  • Tiny & no dependencies — ~4.8 KB gzipped, with nothing to install but React itself - react and react-dom are the only peers.

  • Tree-shakable — Import only what you use to keep bundles small.

  • Minimal re-renders — Only the fields that actually change re-render - never the whole form.

Validation

  • Native HTML constraints — required, min, max, pattern, minLength, maxLength, and more - each with a custom message.

  • Custom rules — Add any synchronous rule with withCustomValidation.

  • Async validation — Run asynchronous rules for server-side checks with withCustomValidationAsync.

  • Schema validation — Any library implementing Standard Schema v1 works out of the box (Zod, Valibot, ArkType, Yup) - drive the whole form from one schema, including cross-field rules, with zero runtime dependencies.

  • Cross-field validation — Re-validate one field when another changes - like confirm-password - via validatorDeps.

Structure & inputs

  • Deeply nested forms — Structure forms however you like, split a big form into focused and reusable components.

  • Dynamic fields — Add or remove fields at runtime without losing state.

  • Real file inputs — type="file" stores the real File object (or File[] with multiple), not the C:\fakepath\... string.

  • Custom data on any input — Attach arbitrary data to a field via dispatchChanges - option lists, loading flags, fetched metadata - kept in form state for your UI, separate from the submitted value.

Platform & standards

  • Type-safe — Typed state, toRawData(), and validators - all inferred from one form interface, no casts.

  • Native <form> actions — Full browser-level submission - action, method, and HTTP navigation - with no JavaScript required.

  • Next.js Server Actions — Works through standard <form> submissions, with no special adapters or client wiring.

  • Accessibility-friendly — Automatically manages aria-required and aria-invalid as validation state changes.

  • React Native — The same API on web and mobile via gform-react/native - no adapters, no separate mental model.

Ready to build better forms?

Install gform-react and ship type-safe, performant forms in minutes.

$npm i gform-react
Read the docs →