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

abit-form

v1.0.5

Published

react form from scratch

Downloads

11

Readme

abit-form

npm version License: MIT

A lightweight React form library with TypeScript support, providing hooks for form state management and validation with both controlled and uncontrolled mode support.

Features

  • 🚀 Simple form state management (both controlled and uncontrolled modes)
  • 🔍 Built-in validation support (change or blur validation triggers)
  • 💡 TypeScript first design with full type safety
  • 🧩 Custom hook architecture with minimal re-renders
  • ⚡ Optimized performance with useCallback and useMemo
  • 📝 Form context support for state sharing
  • 🎯 Automatic error scrolling to first invalid field
  • 🔄 Easy form reset functionality
  • 📦 Lightweight with zero dependencies

Installation

npm install abit-form
# or
yarn add abit-form

Basic Usage

Using the useForm hook

import { useForm } from 'abit-form';

function MyForm() {
  const { register, handleSubmit, errors } = useForm({
    initialValues: {
      email: '',
      password: '',
      rememberMe: false,
    },
    validate: (values) => {
      const errors = {};
      if (!values.email) errors.email = 'Email is required';
      if (!values.password) errors.password = 'Password is required';
      return errors;
    },
  });

  const onSubmit = (values) => {
    console.log('Form submitted:', values);
  };

  return (
    <form onSubmit={handleSubmit(onSubmit)}>
      <input {...register('email')} type="email" />
      {errors.email && <span>{errors.email}</span>}

      <input {...register('password')} type="password" />
      {errors.password && <span>{errors.password}</span>}

      <label>
        <input {...register('rememberMe')} type="checkbox" />
        Remember me
      </label>

      <button type="submit">Submit</button>
    </form>
  );
}

Using Form Context

import { createFormContext, useForm } from 'abit-form';

const [FormProvider, useFormContext] = createFormContext();

function FormWrapper() {
  const form = useForm({
    initialValues: { username: '' },
    validate: (values) => {
      const errors = {};
      if (!values.username) errors.username = 'Username is required';
      return errors;
    },
  });

  return (
    <FormProvider value={form}>
      <NestedFormComponent />
    </FormProvider>
  );
}

function NestedFormComponent() {
  const { register, handleSubmit } = useFormContext();

  return (
    <form onSubmit={handleSubmit((values) => console.log(values))}>
      <input {...register('username')} />
      <button type="submit">Submit</button>
    </form>
  );
}

API Reference

useForm(options)

The main form hook that manages form state and validation.

Options

| Name | Type | Required | Default | Description | | ------------------- | ------------------------------------ | -------- | ---------------- | ------------------------------------------------- | | initialValues | Record<string, any> | ✅ | – | Initial values for the form fields | | mode | 'controlled' | 'uncontrolled' | ❌ | 'uncontrolled' | Form control mode | | validateInputType | 'change' | 'blur' | ❌ | 'blur' | When to trigger validation | | validate | (values) => Record<string, string> | ❌ | – | Validation function that returns an errors object |

Return Value

| Name | Type | Description | | -------------- | ------------------------- | -------------------------------------------- | | register | Function | Function to register form inputs | | handleSubmit | Function | Form submission handler | | errors | Record<string, string> | Current validation errors | | touchedItems | Record<string, boolean> | Object tracking touched fields | | getValues | Function | Function to get current form values | | reset | Function | Function to reset the form to initial values |

createFormContext()

Creates a form context provider and hook for sharing form state across components.

Return Value

| Name | Type | Description | | ---------------- | ---------- | --------------------------------------------------- | | FormProvider | React.FC | Provider component to wrap your form | | useFormContext | Function | Hook to access the shared form state inside context |

License MIT