Embed a contact form in a React SPA
Add a working, spam-protected contact form to a React single-page app — no backend needed.
- 1
Install the SDK
Run `npm i @formloom/client` in your React project.
- 2
Use the hook
Import `useFormLoom` and call it with your access key to get submit and state.
- 3
Render the form
Bind the hook's handlers to a controlled React form and show the returned pending/error/success states.
example.tsx
import { useFormLoom } from "@formloom/client/react";
export function ContactForm() {
const { submit, pending, success } = useFormLoom("YOUR_ACCESS_KEY");
if (success) return <p>Message sent!</p>;
return (
<form onSubmit={submit}>
<input name="email" type="email" required />
<textarea name="message" required />
<button disabled={pending}>Send</button>
</form>
);
}FAQ
No — the browser POSTs directly to FormLoom. No Express or API route needed.