Skip to content

formbase-dev/formbase-react-example

Repository files navigation

Formbase + React Example

A simple contact form example using React and Formbase.

What is Formbase?

Formbase is a form backend service that handles form submissions for you. No server code needed - just point your form to Formbase and receive submissions via email or webhooks.

Quick Start

  1. Clone this repository:

    git clone https://github.com/formbase-dev/formbase-react-example.git
    cd formbase-react-example
  2. Install dependencies:

    bun install
  3. Configure your Form ID:

    • Sign up at formbase.dev and create a form
    • Copy your Form ID
    • Open src/components/ContactForm.tsx and replace YOUR_FORM_ID with your actual Form ID
  4. Start the development server:

    bun run dev

How it Works

  1. User fills out the contact form (name, email, message)
  2. On submit, the form data is POSTed to https://formbase.dev/s/{YOUR_FORM_ID}
  3. Formbase processes the submission and sends you a notification
  4. User is redirected to a thank-you page

Project Structure

├── src/
│   ├── components/
│   │   └── ContactForm.tsx    # Form component with loading state
│   ├── pages/
│   │   ├── Home.tsx           # Home page with contact form
│   │   └── ThankYou.tsx       # Success page after submission
│   ├── index.css              # Tailwind CSS
│   └── main.tsx               # App entry point with routing
├── index.html
├── package.json
├── tsconfig.json
└── vite.config.ts

Customization

Adding Fields

Add new input fields in ContactForm.tsx:

<div>
  <label htmlFor="phone">Phone</label>
  <input type="tel" id="phone" name="phone" />
</div>

Changing Styles

This project uses Tailwind CSS. Modify the classes on any element to change its appearance.

Tech Stack

Links

License

MIT

About

Formbase + React example

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published