apps/docs/skills/zod-to-form/SKILL.md
Use when working with zod-to-form (core, react, cli, codegen, vite).
npx skillsauth add pradeepmouli/zod-to-form zod-to-formInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use this skill for ANY work with zod-to-form. It routes to the correct package.
Use this router when:
Two paths to forms:
z2f.config.ts, run npx zod-to-form generate,
get static .tsx components. Zero runtime overhead, hand-readable output.walkSchema() and render dynamically with useZodForm() in React.Both paths share the same core: a recursive schema walker that produces FormField[]
from Zod v4's native introspection API.
Provides the <ZodForm> component and useZodForm() hook for dynamically rendering
forms from a z.object() schema at runtime — no codegen required. Use this package
when you need schema-driven forms that adapt to runtime schema changes.
Key exports:
ZodForm — the top-level form component; wraps RHF FormProvideruseZodForm — hook that calls walkSchema and wires up RHF for younormalizeFormValues — call before schema.safeParse() to convert HTML empty stringsdefaultComponentMap — the built-in HTML component setshadcnComponentMap — the shadcn/ui component setwrapWithSchemaLite — wrap a submit handler with the lite schema for optimized validationDrives the full code generation pipeline: loads a schema file, walks the Zod internal
type tree via @zod-to-form/core, applies per-field overrides from z2f.config.ts,
and emits static .tsx form components — optionally alongside a Next.js server action
and a schema-lite file for optimized client-side validation.
Provides the building blocks for generating React form TSX files from a
FormField[] tree and a ZodFormsConfig. No Node.js dependencies — safe
to import in browser and server environments alike.
Key exports:
generateFormComponent — produce a complete TSX form component stringgetFileHeader — emit import declarations for generated filesrenderField — render a single field to its JSX stringbuildConfigSource — generate a z2f.config.ts starter filegetFieldTemplateSource — emit the preset FieldTemplate component sourcegenerateSchemaLiteFile — emit the lite schema file for optimized validation?z2f imports into generated form components and replaces <ZodForm> JSX call sites with static output at build time.Two modes:
?z2f imports): import a schema file with a ?z2f query
parameter to receive a fully-generated React form component as a virtual
module. Zero build step — the plugin compiles on demand.options.generate): scan JSX source files for
<ZodForm> call sites and replace statically-resolvable ones with
generated form components at build time. Opt-in via generate: {}.Config resolution order:
options.configPath if explicitly providedz2f.config.{ts,mts,js,mjs} in the Vite rootDEFAULT_CONFIG merged with options.configOverrideTwo paths to forms:
z2f.config.ts, run npx zod-to-form generate,
get static .tsx components. Zero runtime overhead, hand-readable output.walkSchema() and render dynamically with useZodForm() in React.Both paths share the same core: a recursive schema walker that produces FormField[]
from Zod v4's native introspection API.? → zod-to-form-core
2. Runtime React renderer for Zod v4 form schemas — wraps react-hook-form with a schema walker that maps Zod types to form components.
Provides the <ZodForm> component and useZodForm() hook for dynamically rendering
forms from a z.object() schema at runtime — no codegen required. Use this package
when you need schema-driven forms that adapt to runtime schema changes.
Key exports:
ZodForm — the top-level form component; wraps RHF FormProvideruseZodForm — hook that calls walkSchema and wires up RHF for younormalizeFormValues — call before schema.safeParse() to convert HTML empty stringsdefaultComponentMap — the built-in HTML component setshadcnComponentMap — the shadcn/ui component setwrapWithSchemaLite — wrap a submit handler with the lite schema for optimized validation? → zod-to-form-reactDrives the full code generation pipeline: loads a schema file, walks the Zod internal
type tree via @zod-to-form/core, applies per-field overrides from z2f.config.ts,
and emits static .tsx form components — optionally alongside a Next.js server action
and a schema-lite file for optimized client-side validation.? → zod-to-form-cli
4. Browser-safe code generation utilities for Zod v4 form components.
Provides the building blocks for generating React form TSX files from a
FormField[] tree and a ZodFormsConfig. No Node.js dependencies — safe
to import in browser and server environments alike.
Key exports:
generateFormComponent — produce a complete TSX form component stringgetFileHeader — emit import declarations for generated filesrenderField — render a single field to its JSX stringbuildConfigSource — generate a z2f.config.ts starter filegetFieldTemplateSource — emit the preset FieldTemplate component sourcegenerateSchemaLiteFile — emit the lite schema file for optimized validation? → zod-to-form-codegen?z2f imports into generated form components and replaces <ZodForm> JSX call sites with static output at build time.Two modes:
?z2f imports): import a schema file with a ?z2f query
parameter to receive a fully-generated React form component as a virtual
module. Zero build step — the plugin compiles on demand.options.generate): scan JSX source files for
<ZodForm> call sites and replace statically-resolvable ones with
generated form components at build time. Opt-in via generate: {}.Config resolution order:
options.configPath if explicitly providedz2f.config.{ts,mts,js,mjs} in the Vite rootDEFAULT_CONFIG merged with options.configOverride? → zod-to-form-vitezod-to-form-coreRequires Zod v4 — uses _zod.def, _zod.bag, and z.registry() APIs.
Does NOT work with Zod v3 (which uses _def internals).
defineConfig is the typed entry point; bare object literals lose generic inference on components.overridesKey APIs: canonicalizeConfig, createOptimizers, createSchemaLiteCollector
zod-to-form-reactChoose your abstraction level: <ZodForm> for zero-config, useZodForm for custom
rendering, manual walkSchema for full control. Each step down trades convenience for
flexibility.
<ZodForm> and the CLI share the same walkSchema output so the migration is mechanicalform instance (e.g. to call form.setValue)Key APIs: ZodForm, useZodForm, useExternalSync
zod-to-form-cliBefore using the CLI, decide: are you scripting (use runGenerate) or interacting
(use npx zod-to-form)? For config authoring, always use defineConfig for type inference.
dryRun output for preview/diffing without touching the filesystemKey APIs: runGenerate, createProgram, defineConfig
zod-to-form-codegenFormField[] and needs the TSX stringKey APIs: generateFormComponent, resolveFieldMapping, getFileHeader
zod-to-form-viteTwo modes: ?z2f query imports (transform per-import, HMR works) vs generate mode
(static JSX rewriting, no HMR integration). Use ?z2f for new forms, generate for
migrating existing <ZodForm> call sites.
import SignupForm from './signup.schema?z2f' to Just Work in a Vite app — the plugin intercepts the import and compiles the form on demand<ZodForm> call sites — opt in via generate: {} in plugin optionsKey APIs: Z2FViteError, z2fVite, formatZ2FViteError
Top pitfall per package:
componentConfig without a matching components map that covers the component names referenced — missing components are silently dropped at render time with no console error; add each name to components or use defaultComponentMap as the base (react)result.code as the on-disk file content when overwrite is false — if the output file already exists, runGenerate returns wroteFile: false and the existing file is unchanged without throwing; FIX: check result.wroteFile before assuming the file was updated, or set defaults.overwrite: true explicitly (cli)generateFormComponent with a stale fields array from a previous schema version — there is no cache invalidation; callers must re-run walkSchema on schema change (codegen)?z2f on schemas with cyclic type references — the schema walker recurses on Zod's internal type graph and hangs with no error or timeout; FIX: break cycles with z.lazy() before using the ?z2f import (vite)| Thought | Reality | |---------|---------| | "I'll just use core for everything" | core is for schema-driven form generation for zod v4.
two paths to forms:
z2f.config.ts, run npx zod-to-form generate,
get static .tsx components. zero runtime overhead, hand-readable output.walkschema() and render dynamically with usezodform() in react.both paths share the same core: a recursive schema walker that produces formfield[]
from zod v4's native introspection api.. You only need whole-schema validation — omit the optimization option entirely |
| "I'll just use react for everything" | react is for runtime react renderer for zod v4 form schemas — wraps react-hook-form with a schema walker that maps zod types to form components.
provides the <zodform> component and usezodform() hook for dynamically rendering
forms from a z.object() schema at runtime — no codegen required. use this package
when you need schema-driven forms that adapt to runtime schema changes.
key exports:
zodform — the top-level form component; wraps rhf formproviderusezodform — hook that calls walkschema and wires up rhf for younormalizeformvalues — call before schema.safeparse() to convert html empty stringsdefaultcomponentmap — the built-in html component setshadcncomponentmap — the shadcn/ui component setwrapwithschemalite — wrap a submit handler with the lite schema for optimized validation. Bundle size is critical — use CLI codegen (@zod-to-form/cli) instead; runtime schema walking includes the full Zod type graph traversal, which does not tree-shake |
| "I'll just use cli for everything" | cli is for @zod-to-form/cli — build-time cli for generating react form components from zod v4 schemas.drives the full code generation pipeline: loads a schema file, walks the zod internal
type tree via @zod-to-form/core, applies per-field overrides from z2f.config.ts,
and emits static .tsx form components — optionally alongside a next.js server action
and a schema-lite file for optimized client-side validation.. Interactive use — run npx zod-to-form generate (via createProgram()) instead |
| "I'll just use codegen for everything" | codegen is for browser-safe code generation utilities for zod v4 form components.
provides the building blocks for generating react form tsx files from a
formfield[] tree and a zodformsconfig. no node.js dependencies — safe
to import in browser and server environments alike.
key exports:
generateformcomponent — produce a complete tsx form component stringgetfileheader — emit import declarations for generated filesrenderfield — render a single field to its jsx stringbuildconfigsource — generate a z2f.config.ts starter filegetfieldtemplatesource — emit the preset fieldtemplate component sourcegenerateschemalitefile — emit the lite schema file for optimized validation. You want file-writing behavior — use runGenerate() from @zod-to-form/cli instead |
| "I'll just use vite for everything" | vite is for vite plugin for zod-to-form — transforms ?z2f imports into generated form components and replaces <zodform> jsx call sites with static output at build time.two modes:
?z2f imports): import a schema file with a ?z2f query
parameter to receive a fully-generated react form component as a virtual
module. zero build step — the plugin compiles on demand.options.generate): scan jsx source files for
<zodform> call sites and replace statically-resolvable ones with
generated form components at build time. opt-in via generate: {}.config resolution order:
options.configpath if explicitly providedz2f.config.{ts,mts,js,mjs} in the vite rootdefault_config merged with options.configoverride. You are building with webpack, esbuild, Rollup, or any non-Vite bundler — use @zod-to-form/cli instead |User: "I need to schema-driven form generation for zod v4.
two paths to forms:
z2f.config.ts, run npx zod-to-form generate,
get static .tsx components. zero runtime overhead, hand-readable output.walkschema() and render dynamically with usezodform() in react.both paths share the same core: a recursive schema walker that produces formfield[]
from zod v4's native introspection api."
→ Load zod-to-form-core
User: "I need to runtime react renderer for zod v4 form schemas — wraps react-hook-form with a schema walker that maps zod types to form components.
provides the <zodform> component and usezodform() hook for dynamically rendering
forms from a z.object() schema at runtime — no codegen required. use this package
when you need schema-driven forms that adapt to runtime schema changes.
key exports:
zodform — the top-level form component; wraps rhf formproviderusezodform — hook that calls walkschema and wires up rhf for younormalizeformvalues — call before schema.safeparse() to convert html empty stringsdefaultcomponentmap — the built-in html component setshadcncomponentmap — the shadcn/ui component setwrapwithschemalite — wrap a submit handler with the lite schema for optimized validation"zod-to-form-reactUser: "I need to @zod-to-form/cli — build-time cli for generating react form components from zod v4 schemas.
drives the full code generation pipeline: loads a schema file, walks the zod internal
type tree via @zod-to-form/core, applies per-field overrides from z2f.config.ts,
and emits static .tsx form components — optionally alongside a next.js server action
and a schema-lite file for optimized client-side validation."
→ Load zod-to-form-cli
User: "I need to browser-safe code generation utilities for zod v4 form components.
provides the building blocks for generating react form tsx files from a
formfield[] tree and a zodformsconfig. no node.js dependencies — safe
to import in browser and server environments alike.
key exports:
generateformcomponent — produce a complete tsx form component stringgetfileheader — emit import declarations for generated filesrenderfield — render a single field to its jsx stringbuildconfigsource — generate a z2f.config.ts starter filegetfieldtemplatesource — emit the preset fieldtemplate component sourcegenerateschemalitefile — emit the lite schema file for optimized validation"zod-to-form-codegenUser: "I need to vite plugin for zod-to-form — transforms ?z2f imports into generated form components and replaces <zodform> jsx call sites with static output at build time.
two modes:
?z2f imports): import a schema file with a ?z2f query
parameter to receive a fully-generated react form component as a virtual
module. zero build step — the plugin compiles on demand.options.generate): scan jsx source files for
<zodform> call sites and replace statically-resolvable ones with
generated form components at build time. opt-in via generate: {}.config resolution order:
options.configpath if explicitly providedz2f.config.{ts,mts,js,mjs} in the vite rootdefault_config merged with options.configoverride"zod-to-form-vitedevelopment
Configuration for zod-to-form code generation (defineConfig / z2f.config.ts): component library, generation defaults, file selection, and per-schema overrides. Also: zod, zod-v4, forms, form-generation, schema, schema-walker, processor-registry, react-hook-form, schema-driven, form-schema, zod-registry.
tools
Vite plugin for zod-to-form — transforms ?z2f imports into generated form components and optionally replaces <ZodForm> JSX call sites with generated components at build time Use when: You want `import SignupForm from './signup.schema?z2f'` to Just Work in a.... Also: vite, vite-plugin, zod, zod-v4, codegen, forms, form-generation, schema-driven, react-hook-form, build-plugin, jsx-transform.
development
Runtime <ZodForm> renderer for Zod v4 schemas Use when: You need form rendering in storybook, playgrounds, or low-traffic admin UIs —.... Also: zod, zod-v4, react, forms, form-generation, react-hook-form, schema-driven, dynamic-forms, form-renderer, hookform-resolver, zod-form-renderer.
development
Schema walker and processor registry for Zod v4 form generation Use when: You want per-field validation instead of whole-form validation. Also: zod, zod-v4, forms, form-generation, schema, schema-walker, processor-registry, react-hook-form, schema-driven, form-schema, zod-registry.