npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@zod-to-form/react

v0.6.2

Published

Runtime <ZodForm> renderer for Zod v4 schemas

Readme

@zod-to-form/react

Runtime React renderer for Zod v4 schemas.

@zod-to-form/react integrates @zod-to-form/core with React Hook Form and renders schema-driven forms using ZodForm and useZodForm.

Installation

pnpm add @zod-to-form/react @zod-to-form/core zod react react-hook-form @hookform/resolvers

Requirements

  • React 18+ (React 19 supported)
  • React Hook Form 7+
  • Zod v4

Quick Start

import { z } from 'zod';
import { ZodForm } from '@zod-to-form/react';

const userSchema = z.object({
  name: z.string().min(1),
  email: z.string().email(),
  subscribe: z.boolean().default(false)
});

export function UserForm() {
  return (
    <ZodForm
      schema={userSchema}
      mode='onSubmit'
      onSubmit={(data) => {
        console.log('submitted', data);
      }}
    >
      <button type='submit'>Save</button>
    </ZodForm>
  );
}

API

ZodForm

Props:

  • schema: Zod object schema (required)
  • onSubmit: submit handler with parsed schema output
  • onValueChange: called with parsed output on valid field updates
  • mode: 'onSubmit' | 'onChange' | 'onBlur'
  • defaultValues: partial initial values
  • components: partial override map for default components
  • componentConfig: runtime component mapping/field overrides
  • formRegistry: metadata registry from @zod-to-form/core
  • processors: custom/override processors from @zod-to-form/core
  • className: class passed to <form>
  • children: rendered inside the <form> (typically actions)

useZodForm

Returns:

  • form: React Hook Form instance
  • fields: walked FormField[] descriptors from schema
import { z } from 'zod';
import { useZodForm } from '@zod-to-form/react';

const schema = z.object({ title: z.string().min(1) });

export function Example() {
  const { form, fields } = useZodForm(schema, {
    mode: 'onChange',
    onValueChange: (values) => {
      console.log(values);
    }
  });

  return <pre>{JSON.stringify({ fieldCount: fields.length, dirty: form.formState.isDirty })}</pre>;
}

Components

defaultComponentMap

Built-in default component map used by ZodForm.

shadcnComponentMap

Shadcn-oriented component map export.

Runtime Component Config

Use componentConfig to map specific field paths to custom components and apply per-component overrides at runtime.

import { ZodForm } from '@zod-to-form/react';
import type { RuntimeComponentConfig } from '@zod-to-form/react';

const componentConfig: RuntimeComponentConfig = {
  components: {
    source: '@/components/form-components',
    overrides: {
      TextareaInput: { controlled: false },
    },
  },
  fields: {
    'profile.bio': {
      component: 'TextareaInput',
      props: { rows: 6 }
    }
  }
};

// <ZodForm schema={schema} componentConfig={componentConfig} />

Accessibility

  • Uses native form semantics (<form>, labels, fieldsets/legends where applicable)
  • Supports error propagation from React Hook Form state into rendered fields
  • Includes accessibility-focused integration tests in this package

Development

From repository root:

pnpm --filter @zod-to-form/react run build
pnpm --filter @zod-to-form/react run test
pnpm --filter @zod-to-form/react run type-check