A working React contact form that sends submissions with the Formclick form API. No backend, no server code: one fetch() call, and every message lands in your inbox and your Formclick dashboard.
Built with React 19 and Vite.
- Create a free account at formclick.io, create a form and copy its access key.
- Clone and install:
git clone https://github.com/formclick/react-contact-form.git cd react-contact-form npm install - Copy
.env.exampleto.envand paste your key:VITE_FORMCLICK_ACCESS_KEY=your-access-key
- Run
npm run dev, open the page and send a test message.
The Free plan includes 250 submissions a month. See pricing.
All the logic is in src/ContactForm.jsx:
const data = Object.fromEntries(new FormData(form));
const res = await fetch('https://api.formclick.io/submit', {
method: 'POST',
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
body: JSON.stringify({ ...data, access_key: ACCESS_KEY }),
});
const result = await res.json(); // { success, message }| Piece | Why it's there |
|---|---|
import.meta.env.VITE_FORMCLICK_ACCESS_KEY |
Vite exposes VITE_ variables to the browser. The access key can only create submissions, so it's safe in client code. |
new FormData(form) |
Collects every input with a name, so adding a field to the form is all you need to send it. |
_honeypot input |
A hidden spam trap. People never fill it; bots do, and those submissions are silently discarded. |
status state |
Drives the button label (Sending…), the error message and the thank-you screen. |
res.status === 429 |
Formclick limits how often one visitor can submit; the form shows a friendly "wait a few minutes" message. |
result.message |
On errors, Formclick returns a readable reason (for example "Form not found"), shown to the visitor. |
{ "success": true, "message": "Thank you! Your message has been received." }| Status | Meaning |
|---|---|
200 |
Saved and delivered. |
400 |
Missing or invalid access key, empty submission, or a failed captcha. |
403 |
Form disabled, website not on the form's allowed domains, or monthly limit reached. |
404 |
No form exists for this access key. |
429 |
Too many submissions from one visitor in a short time. |
- More fields: add any
<input name="…">; it's sent automatically. - Email subject: change the
subjectvalue sent with the request. - Your own design: edit
src/styles.cssor swap in your UI library; the submit logic doesn't change. - Next.js? See nextjs-contact-form.
- Form API reference: endpoint, fields, responses and limits
- Documentation
- All Formclick examples