Forms
Write the schema of a form. ViteHub checks each message, stores it, emails you, and shows it in the Console.
Deploys on
- Node
- Docker
- Cloudflare
- Vercel
- Netlify
shared/schemas.ts
import * as v from 'valibot'
export const ContactSchema = v.object({
email: v.pipe(v.string(), v.email()),
message: v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(5000)),
})What you get
Section titled "What you get"| Part | What it does |
|---|---|
| Guard | Accepts only POST, rejects a present Origin unless it is your origin or in origins, blocks large bodies, answers a filled honeypot field with a fake success, and limits each address to 5 messages a minute. Requests without Origin may pass. |
| Validation | Checks each message with your Standard Schema: Valibot, Zod, or ArkType. A bad message gets the error of each field. |
| Inbox | Keeps each message in the vitehub_form_submissions table, with its page and the sentence the sender selected. The Console lists them. |
| Notify | Emails each message to you through Email, with reply-to set to the sender. |
onSubmit | Runs your code before Forms stores the message, for example to post it to a support tool. |
Forms or Comments
Section titled "Forms or Comments"Use Comments when readers talk with each other on the page. Use Forms when messages stay private and go straight to you.
- Get started: add a contact form to a ViteHub app.
- Server API: every option of
defineForm()and the inbox. - Vue:
AutoForm,useFormAction(), anduseFormSubmit()for Formisch.