Skip to content

About

React 19 contact form with Vite, powered by the Formclick form API. One fetch() call, no backend required.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

React contact form

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.

Quick start

  1. Create a free account at formclick.io, create a form and copy its access key.
  2. Clone and install:
    git clone https://github.com/formclick/react-contact-form.git
    cd react-contact-form
    npm install
  3. Copy .env.example to .env and paste your key:
    VITE_FORMCLICK_ACCESS_KEY=your-access-key
  4. Run npm run dev, open the page and send a test message.

The Free plan includes 250 submissions a month. See pricing.

How it works

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.

Responses

{ "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.

Customise it

  • More fields: add any <input name="…">; it's sent automatically.
  • Email subject: change the subject value sent with the request.
  • Your own design: edit src/styles.css or swap in your UI library; the submit logic doesn't change.
  • Next.js? See nextjs-contact-form.

Learn more

License

MIT

About

React 19 contact form with Vite, powered by the Formclick form API. One fetch() call, no backend required.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages