A simple contact form example using Svelte and 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.
-
Clone this repository:
git clone https://github.com/formbase-dev/formbase-svelte-example.git cd formbase-svelte-example -
Install dependencies:
bun install
-
Configure your Form ID:
- Sign up at formbase.dev and create a form
- Copy your Form ID
- Open
src/components/ContactForm.svelteand replaceYOUR_FORM_IDwith your actual Form ID
-
Start the development server:
bun run dev
- User fills out the contact form (name, email, message)
- On submit, the form data is POSTed to
https://formbase.dev/s/{YOUR_FORM_ID} - Formbase processes the submission and sends you a notification
- User is redirected to a thank-you page
├── src/
│ ├── components/
│ │ └── ContactForm.svelte # Form component with loading state
│ ├── pages/
│ │ ├── Home.svelte # Home page with contact form
│ │ └── ThankYou.svelte # Success page after submission
│ ├── app.css # Tailwind CSS
│ ├── App.svelte # Root component with routing
│ └── main.ts # App entry point
├── index.html
├── package.json
├── tsconfig.json
└── vite.config.ts
Add new input fields in ContactForm.svelte:
<div>
<label for="phone">Phone</label>
<input type="tel" id="phone" name="phone" />
</div>This project uses Tailwind CSS. Modify the classes on any element to change its appearance.
- Svelte - UI framework
- Vite - Build tool
- TypeScript - Type safety
- Tailwind CSS - Styling
- svelte-routing - Client-side routing
- Formbase - Form backend service
- Formbase Documentation
- Other Formbase Examples
MIT