react-browser-form
v0.1.10
Published
<div align="center"> <a href="https://deniskabana.github.io/react-browser-form/introduction" title="React Browser Form - Form management in React made simple for browsers."> <img src="https://raw.githubusercontent.com/deniskabana/react-browser-form/
Downloads
33
Maintainers
Readme
React Browser Form is a small React library designed as a single hook intended to handle form usage in React while incentivizing the usage of web forms. It is designed to be flexible, performant, easy to learn and use and to handle even very complex forms while providing full type safety and an amazing developer experience. Read more in FAQ.
Features
- Written with performance 💡, developer experience 🧑💻 and browser standards 🌐 in mind.
- TypeScript-first with full type safety.
- Comes with a TSDoc documentation including links to examples and docs.
- Small size and no dependencies.
- Non-opinionated, flexible and extensible.
- Built-in validation and transformation support.
- Minimal API with emphasis on best practices.
Docs & examples
Visit the Documentation for 🌐📝 React Browser Form.
Install
npm install --save react-browser-form
# OR
yarn add react-browser-form
Quickstart
See the Getting started page in our Docs for more information.
const defaultValues = { title: "" };
export type Form = typeof defaultValues;
export default function FormComponent() {
const onSubmit = React.useCallback((values: Form) => {
console.log(values);
}, []);
const { formProps, names } = useBrowserForm<Form>({
name: "new-form",
defaultValues,
onSubmit,
});
return (
<form {...formProps}>
<input name={names.title} type="text" />
<button type="submit">Subscribe</button>
</form>
);
}