Skip to content

@formerie/react

Formerie for React

Send form submissions from React to Formerie, without holding recipients, templates, or provider keys in your code.

Works with

Install

These packages are in alpha, so their APIs may change.

pnpm

pnpm add @formerie/react

npm

npm install @formerie/react

Yarn

yarn add @formerie/react

Bun

bun add @formerie/react

Use it

useFormerieSubmit gives a component a submit function and its state. Your JSX, your styling.

You’ll need a published form. Replace example.com and contact with your workspace and form handles from the app.

import { useFormerieSubmit } from "@formerie/react";

export function ContactForm() {
  const { submit, state } = useFormerieSubmit({
    workspace: "example.com",
    form: "contact",
  });

  async function onSubmit(event: React.FormEvent<HTMLFormElement>) {
    event.preventDefault();

    await submit({
      fields: Object.fromEntries(new FormData(event.currentTarget)),
    });
  }

  return (
    <form onSubmit={onSubmit}>
      <input name="email" type="email" />
      <button disabled={state.status === "submitting"}>Send</button>
    </form>
  );
}

What happens next

Create a workspace and publish your first form.

In early access. New workspaces start on the Free plan.