diff --git a/README.md b/README.md index 2484812b..a9f5b5f1 100644 --- a/README.md +++ b/README.md @@ -2,26 +2,29 @@ Conform is a form validation library built on top of the [Constraint Validation](https://caniuse.com/constraint-validation) API. -- **Progressive Enhancement**: It is designed based on the [HTML specification](https://html.spec.whatwg.org/dev/form-control-infrastructure.html#the-constraint-validation-api). From validating the form to reporting error messages for each field, if you don't like part of the solution, just replace it with your own. -- **Framework Agnostic**: The DOM is the only dependency. Conform makes use of native [Web APIs](https://developer.mozilla.org/en-US/docs/Web/API) exclusively. You don't have to use React / Vue / Svelte to utilise this library. -- **Flexible Setup**: It can validates fields anywhere in the dom with the help of [form attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#form). Also enables CSS pseudo-classes like `:valid` and `:invalid`, allowing flexible styling across your form without the need to manipulate the class names. +- **Progressive Enhancement**: Its APIs are designed with progressive enhancement in mind to ensure a smooth and resillent experience before javascript is ready. +- **Server-first validation**: It simplifies the mental model by utilizing a server-first validation flow which submits your form for validation. +- **Lightweight**: It is only [4kB](https://bundlephobia.com/package/@conform-to/react) compressed thanks to all the native [Web APIs](https://developer.mozilla.org/en-US/docs/Web/API). _#useThePlatform_ ## Quick start - + ```tsx import { useForm, useFieldset } from '@conform-to/react'; export default function LoginForm() { const form = useForm({ - onSubmit(event, { submission }) { + onSubmit(event) { event.preventDefault(); - console.log(submission); + const formData = new FormData(event.currentTarget); + const value = Object.fromEntries(formData); + + console.log(value); }, }); - const { email, password } = useFieldset(form.ref); + const { email, password } = useFieldset(form.ref, form.config); return (