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

@smart-form/react

v0.0.2

Published

React binding for @smart-form/core

Readme

@smart-form/react

React binding for Smart Form - a type-safe form library with Zod validation.

Demo: https://smart-form-docs.vercel.app/docs/examples/react

Installation

Using shadcn CLI (Recommended)

npx shadcn@latest add https://deiucanta.github.io/smart-form/smart-form.json

This automatically installs the package and sets up shadcn/ui components.

Manual Installation

npm install @smart-form/react zod

Quick Start

import { form, SmartForm, type InferFormData } from '@smart-form/react'
import { z } from 'zod'

const myForm = form()
  .text('name', {
    schema: z.string().min(1, 'Name is required'),
    label: 'Full Name',
  })
  .text('email', {
    schema: z.string().email('Invalid email'),
    label: 'Email',
  })
  .select('country', {
    schema: z.enum(['us', 'uk', 'ca']),
    label: 'Country',
    options: [
      { value: 'us', label: 'United States' },
      { value: 'uk', label: 'United Kingdom' },
      { value: 'ca', label: 'Canada' },
    ],
  })

type FormData = InferFormData<typeof myForm>

function App() {
  const handleSubmit = (data: FormData) => {
    console.log(data)
  }

  return (
    <SmartForm
      form={myForm}
      components={myComponents}
      initialValues={{ name: 'John' }}
      onSubmit={handleSubmit}
    />
  )
}

SmartForm Props

| Prop | Type | Required | Description | |------|------|----------|-------------| | form | FormDef | Yes | Form definition created with form() | | components | ComponentRegistry | Yes | UI component registry | | initialValues | object | No | Initial form values | | onSubmit | (data) => void | Yes | Submit handler |

Field Types

form()
  // Text input
  .text('username', {
    schema: z.string().min(3),
    label: 'Username',
    span: 6,  // Grid columns (1-12)
  })

  // Number input
  .text('age', {
    schema: z.coerce.number().min(18),
    inputType: 'number',
  })

  // Textarea
  .textarea('bio', {
    schema: z.string(),
    rows: 5,
  })

  // Select
  .select('role', {
    schema: z.enum(['admin', 'user']),
    options: [
      { value: 'admin', label: 'Admin' },
      { value: 'user', label: 'User' },
    ],
    placeholder: 'Select a role...',
  })

  // Array (repeatable fields)
  .array('items', {
    sortable: true,
    fields: (row) => row
      .text('name', { span: 8 })
      .text('qty', { span: 4 }),
  })

Component Registry

Provide your own UI components to customize the look and feel:

import type { ComponentRegistry } from '@smart-form/react'

const myComponents: ComponentRegistry = {
  TextField: ({ name, value, label, error, onChange, onBlur }) => (
    <div>
      <label>{label}</label>
      <input
        value={value}
        onChange={e => onChange(e.target.value)}
        onBlur={onBlur}
      />
      {error && <span className="error">{error}</span>}
    </div>
  ),

  TextareaField: ({ value, label, rows, error, onChange, onBlur }) => (
    <div>
      <label>{label}</label>
      <textarea
        value={value}
        rows={rows}
        onChange={e => onChange(e.target.value)}
        onBlur={onBlur}
      />
      {error && <span className="error">{error}</span>}
    </div>
  ),

  SelectField: ({ value, label, options, error, onChange, onBlur }) => (
    <div>
      <label>{label}</label>
      <select value={value} onChange={e => onChange(e.target.value)} onBlur={onBlur}>
        {options.map(opt => (
          <option key={opt.value} value={opt.value}>{opt.label}</option>
        ))}
      </select>
      {error && <span className="error">{error}</span>}
    </div>
  ),

  ArrayField: ({ label, value, renderItem, onAdd, onRemove }) => (
    <div>
      <label>{label}</label>
      {value.map((_, index) => (
        <div key={index}>
          {renderItem(index)}
          <button type="button" onClick={() => onRemove(index)}>Remove</button>
        </div>
      ))}
      <button type="button" onClick={onAdd}>Add</button>
    </div>
  ),

  FormWrapper: ({ children, onSubmit }) => (
    <form onSubmit={e => { e.preventDefault(); onSubmit() }}>
      {children}
    </form>
  ),

  SubmitButton: ({ isSubmitting }) => (
    <button type="submit" disabled={isSubmitting}>
      {isSubmitting ? 'Submitting...' : 'Submit'}
    </button>
  ),

  FieldWrapper: ({ span, children }) => (
    <div style={{ gridColumn: `span ${span ?? 12}` }}>
      {children}
    </div>
  ),
}

TypeScript

Full type inference is available:

import { form, type InferFormData } from '@smart-form/react'

const myForm = form()
  .text('name', { schema: z.string() })
  .text('age', { schema: z.coerce.number() })

type FormData = InferFormData<typeof myForm>
// { name: string; age: number }

Related Packages

License

MIT