@formerie/react
v0.1.0-alpha.15
Published
React helpers for the Formerie public API.
Readme
@formerie/react
React helpers for Formerie forms.
Install
npm install @formerie/reactpnpm add @formerie/reactyarn add @formerie/reactbun add @formerie/reactExample
import { FormerieForm } from "@formerie/react";
<FormerieForm form="fm_t77txbvg43nmar" />Replace only the parts you care about, and FormerieFields draws the rest. Put it after the ones you place:
import { FormerieField, FormerieFields, FormerieForm, FormerieSubmit } from "@formerie/react";
<FormerieForm form="fm_t77txbvg43nmar">
<FormerieField name="email">
{({ field, inputProps }) => <MyInput {...inputProps} label={field.label} />}
</FormerieField>
<FormerieFields />
<FormerieSubmit>Send</FormerieSubmit>
</FormerieForm>Or keep your own markup with useFormerieForm:
import { useFormerieForm } from "@formerie/react";
export function ContactForm() {
const { formProps } = useFormerieForm({ form: "fm_t77txbvg43nmar" });
return (
<form {...formProps}>
<input name="email" type="email" />
<span data-formerie-error-for="email" hidden />
<button data-formerie-submit>Send</button>
</form>
);
}Verification, spam checks and errors are taken care of on every level. Drawn fields are plain HTML, so your CSS
reaches them, or pass classes. To draw on a server, give FormerieForm a snapshot from
loadFormerieSnapshot in @formerie/client/server.
form is the form's ID, which you'll find on its page in the app.
