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-plain-form

v2.0.2-beta

Published

React simple form for everyday usage ๐Ÿ˜œ

Readme

React plain form

React simple form for everyday usage ๐Ÿ˜œ

Demo

Example

import React from 'react';
import { render } from 'react-dom';
import useForm from 'react-plain-form';

function Form({ schema }) {
    const {
        fields,
        values,
        isValidating,
        errors
    } = useForm(schema);
    const isErrors = !!Object.keys(errors).length;
    const handleSubmit = e => {
        e && e.preventDefault();
        console.log(values);
    };

    return (
        <form onSubmit={handleSubmit}>
            <label>
                Name
                <input {...fields.name} />
                { errors.name && <span>{errors.name}</span> }
            </label>
            <br/>
            <button
                type="submit"
                disabled={isValidating || isErrors}
            >
                Submit
            </button>
        </form>
    );
}

const formSchema = {
    name: {
        type: 'text',
        onValidate: values => new Promise((res, rej) =>
            values.name.length
                ? res()
                : rej(new Error('Name required'))
        )
    }
};

render(
    <Form schema={formSchema} />,
    document.querySelector('#root')
);

API

useForm({ schema })

| Name | Type | Defaults | Description | | ------------- | ------- | :-------------:| :----- | | schema | Object | undefined | Configuration object for you form | | schema[key] | String | undefined | name prop for future input field | | schema[value].[any] | Object | undefined | Any valid html5 attributes | | schema[value].onValidate | Function | undefined | validation function. Get values as argument and should return Promise. | | schema[value].validateOn | String or Array | change | Validation run on this events. Variants: change focus blur | | schema[value].defaultValue | String | '' | Default value

const {...} = useForm({ schema })

| Name | Type | Description | | ------------- | ------- | :----- | | fields | Object | Same as schema above, but enriched with aditions methods like onChange etc. To make input controllable. | | values | Object | Key, value pairs with name of your input and it current value. | | errors | Object | Key, value pairs with name of your input and it current value. | | isValidating | Boolean | Indicator, Does form is in validating state right now or not. | | setError | Function | Set error for field. setError(name, value). | | setValue | Function | Set value for field. setValue(name, value). | | validateAll | Function | Run all onValidate concurrently. Returns promise. Usefull to run validation on submit | | updateFields | Function | Want to add fields dynamically, pass as argument to this function new created or extended schema |