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

react-f0rm

v0.2.2

Published

react form

Readme

react-f0rm

Features

  • Drive by event.
  • Refined tree-shaking support. Needn't have to pay for features not used.
  • Theoretically more efficient(need a benchmark).

Install

npm i react-f0rm

or

yarn add react-f0rm

Usage

import React from 'react';
import {Form, Field} from 'react-f0rm';

export default function Register() {
  return (
    <Form
      initialValues={{name: 'wmzy', email: '[email protected]'}}
      onValidSubmit={values => console.log(values)}
    >
      <Field name="name" />
      <Field name="email" />
      <button>SUBMIT</button>
    </Form>
  );
}

Hooks

useField

For full control over field rendering:

import {useField} from 'react-f0rm';

function CustomField({name}) {
  const {value, onChange, onBlur, error} = useField({name});
  return (
    <div>
      <input value={value} onChange={e => onChange(e.target.value)} onBlur={onBlur} />
      {error && <span>{error}</span>}
    </div>
  );
}

useFieldArray

Manage dynamic lists of fields:

import {useFieldArray} from 'react-f0rm';

function Tags() {
  const {fields, append, remove} = useFieldArray({name: 'tags'});
  return (
    <div>
      {fields.map((field, index) => (
        <div key={field.id}>
          <Field name={['tags', index]} />
          <button type="button" onClick={() => remove(index)}>Remove</button>
        </div>
      ))}
      <button type="button" onClick={() => append('')}>Add Tag</button>
    </div>
  );
}

Submit Handlers

<Form
  initialValues={{email: ''}}
  onValidSubmit={(values, e) => {
    // Called after successful validation
    saveToServer(values);
  }}
  onInvalidSubmit={(errors, values) => {
    // Called when validation fails
    console.error(errors);
  }}
>
  <Field name="email" />
  <button>Submit</button>
</Form>

Validation

Field-level validation

Pass a validate function to Field or useField. Return an error string or undefined:

<Field
  name="email"
  validate={value => {
    if (!value.includes('@')) return 'Invalid email';
  }}
/>

Form-level validation

Pass a validate function to createForm. It receives all values and returns an object of errors:

import {createForm} from 'react-f0rm';

const form = createForm({
  initialValues: {password: '', confirm: ''},
  validate: values => {
    const errors = {};
    if (values.password !== values.confirm) {
      errors.confirm = 'Passwords do not match';
    }
    return errors;
  },
});

Custom Components

Use the as prop to render a custom component instead of <input>:

function TextArea({value, onChange, ...props}) {
  return <textarea {...props} value={value} onChange={e => onChange(e.target.value)} />;
}

<Field name="bio" as={TextArea} />

TypeScript

import {Form, Field, useForm, createForm} from 'react-f0rm';

interface UserForm {
  name: string;
  email: string;
}

const form = createForm<UserForm>();

function MyForm() {
  return (
    <Form<UserForm>
      form={form}
      onValidSubmit={values => {
        // values is typed as UserForm
        console.log(values.name);
      }}
    >
      <Field name="name" />
      <Field name="email" />
      <button>Submit</button>
    </Form>
  );
}