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

@avinlab/react-form

v0.4.0

Published

A React library for building forms with ease, providing hooks for managing form state and validation in React applications.

Downloads

36

Readme

@avinlab/react-form

A React library for building forms with ease, providing hooks for managing form state and validation in React applications.

Features

  • 🎯 Easy to use: Simple API for managing form state with minimal boilerplate.
  • 🔧 Customizable: Extendable to fit the needs of your specific form logic.
  • 🚀 Performance: Optimized to reduce unnecessary renders and improve performance.

Installation

npm install @avinlab/react-form

Playground

Online example is here

Usage

Create form with validation:

import React from 'react';
import { useForm, useFormValidation, useFormWatch } from '@avinlab/react-form';

const ExampleForm = () => {
  const form = useForm({ name: 'Bob', age: 20 });

  const { errors, isValid, validate } = useFormValidation(form, (values, prevValues) => {
    const errors = {};
    if (!values.name) {
      errors.name = 'Name is required';
    }
    if (values.age && values.age < 18) {
      errors.age = 'Must be at least 18';
    }
    return errors;
  });

  const handleSubmit = (e) => {
    e.preventDefault();
    if (isValid) {
      console.log(form.values);
    }
  };

  // If you want to render the form values:
  // const nameValue = useFormWatch(form, 'name');
  // const formValuesObj = useFormWatch(form);

  return (
    <form onSubmit={handleSubmit}>
      <input
        name="name"
        defaultValue={form.values.name}
        onChange={(e) => form.setValue('name', e.currentTarget.value)}
      />
      {errors.name && <span className="error">{errors.name}</span>}

      <input
        name="age"
        defaultValue={form.values.age}
        onChange={(e) => form.setValue('name', e.currentTarget.value)}
      />
      {errors.name && <span className="error">{errors.name}</span>}

      <button type="submit" disabled={!isValid}>
        Submit
      </button>
    </form>
  );
};

Examples

For more advanced examples, check out the example directory.

Creating controlled components faster

You can use createFormComponent helper to quickly bind form fields to the form state:

import { createFormComponent, useForm } from '@avinlab/react-form';

const TextInput = ({ label, ...props }) => (
  <label className="block">
    <span className="block text-sm font-semibold text-gray-700 mb-1">{label}</span>
    <input className="input w-full" {...props} />
  </label>
);

const FormTextInput = createFormComponent(TextInput, {
  getValue: (event) => event.currentTarget.value,
});

const CheckboxInput = ({ label, ...props }) => (
  <label className="inline-flex items-center space-x-2">
    <input type="checkbox" {...props} />
    <span>{label}</span>
  </label>
);

const FormCheckboxInput = createFormComponent(CheckboxInput, {
  valueAttrName: 'checked',
  getValue: (event) => event.target.checked,
});

export function ProfileForm() {
  const form = useForm({ email: '', accepted: false });

  return (
    <form className="space-y-4">
      <FormTextInput form={form} name="email" label="Email" placeholder="[email protected]" />
      <FormCheckboxInput form={form} name="accepted" label="I agree with the terms" />
    </form>
  );
}

createFormComponent accepts an optional options object as a second argument:

  • valueAttrName – name of the prop that receives the form value (defaults to "value").
  • onChangeAttrName – name of the change handler prop (defaults to "onChange").
  • getValue(event) – function that extracts the value to store in the form. By default it simply returns whatever is passed as the first argument of the onChange handler.