react-browser-form
Version:
<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/
68 lines (50 loc) • 2.86 kB
Markdown
<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/main/docs/public/github-logo.png" alt="🌐📝 React Browser Form - React hook for form management in web browsers." />
</a>
</div>
<div align="center">




</div>
---
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](https://developer.mozilla.org/en-US/docs/Learn/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](https://deniskabana.github.io/react-browser-form/frequently-asked-questions).
---
1. Written with performance 💡, developer experience 🧑💻 and browser standards 🌐 in mind.
2. TypeScript-first with full type safety.
3. Comes with a [TSDoc documentation](https://github.com/deniskabana/react-browser-form/blob/main/src/types.ts) including links to examples and docs.
4. [Small size](https://bundlephobia.com/result?p=react-browser-form@latest) and no [dependencies](./package.json).
5. Non-opinionated, flexible and extensible.
6. Built-in [validation and transformation](https://deniskabana.github.io/react-browser-form/documentation/validation-and-transformation) support.
7. Minimal API with emphasis on best practices.
Visit the [Documentation for 🌐📝 React Browser Form](https://deniskabana.github.io/react-browser-form/).
npm install --save react-browser-form
yarn add react-browser-form
See the [Getting started](https://deniskabana.github.io/react-browser-form/getting-started) page in our Docs for more information.
```tsx
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>
);
}
```