Forms — KorDent Astro
The four forms of this Astro template work as soon as you run it: the booking form, the contact form, the review form and the newsletter.
The booking form is on Book, on the Services page and on every service page; the contact form on Contact; the review form (“Share Your Experience”) on Home and on the Services page; the newsletter (“Smile Bulletin”) in the footer of every page. Each form checks the required fields, shows a spinner while sending, says “Thank you” and clears the fields, keeps what the visitor typed when something fails (“Something went wrong”), and drops spam with a hidden honeypot field.
Out of the box they run in demo mode: nothing is sent, and the fields are logged in the browser console. That’s fine while you build, but useless once you publish, so pick a destination before launch. One destination serves all four forms; every submission says which form it came from, so you can tell them apart in your inbox or tool.
The quickest way to receive submissions
Section titled “The quickest way to receive submissions”| You want | Mode | Hosting |
|---|---|---|
| An email for every submission, with no server to run | Static: a form service (Formspree, Web3Forms, Getform, Basin) | Any static host |
| Submissions in your practice software, CRM, Slack, a spreadsheet… | Static: a webhook (Zapier, Make, n8n, Pipedream) | Any static host |
| Resend or Mailchimp directly, with no third party in between | Server: the site’s own route (below) | A host with an Astro adapter |
Most sites want static mode: it keeps the site 100% static and takes two minutes.
-
Create a form at your service and copy its endpoint URL (Formspree:
https://formspree.io/f/<id>). -
Copy the example settings and paste the URL:
Terminal window cp .env.example .envPUBLIC_FORM_ENDPOINT=https://formspree.io/f/abcdwxyzWeb3Forms also needs
PUBLIC_FORM_ACCESS_KEY. -
Restart
npm run devand send a test from each form. -
If your host builds the site, put the same variable in its dashboard before deploying:
.envstays on your computer (it is not in Git). The value is written into the pages when the site builds, so rebuild after changing it.
The endpoint is public (it is in the page), which is how these services are designed to work; they filter spam on
their side. All four forms post to the same endpoint, with form (booking, contact, review or newsletter) and
subject (the submission’s title) next to the fields. Details for each service are in
Forms reference.
Server mode
Section titled “Server mode”For Resend or Mailchimp without a third-party service, the forms post to a route on your own site:
-
Add the adapter for your host:
npx astro add vercel(ornetlify,node, …). -
Set
PUBLIC_FORM_MODE=server, and choose where submissions go withFORM_PROVIDER:You want Set An email for every submission FORM_PROVIDER=resend+RESEND_API_KEY,FORM_EMAIL_TO,FORM_EMAIL_FROMIt in your CRM, Slack, a spreadsheet… FORM_PROVIDER=webhook+FORM_WEBHOOK_URL(Zapier, Make, n8n, Formspree, your own API);FORM_WEBHOOK_SECRETis optionalThe sender in a Mailchimp audience FORM_PROVIDER=mailchimp+MAILCHIMP_API_KEY,MAILCHIMP_AUDIENCE_ID;MAILCHIMP_STATUSis optionalThe server log only, while you test FORM_PROVIDER=console(the default)Several at once work:
FORM_PROVIDER=resend,mailchimp. -
Restart
npm run devand send a test from each form. The forms now post to/api/forms/booking,/api/forms/contact,/api/forms/reviewand/api/forms/newsletter(src/lib/forms/route.ts, added bysrc/integrations/forms.ts); every page stays static, only that route runs on the server. -
Put the same variables in your host’s dashboard before deploying, and redeploy after changing them.
Details for each provider, what it receives, the webhook payload, Mailchimp consent settings and how to write your own provider are in Forms reference.
What the forms ask for
Section titled “What the forms ask for”The booking form (form booking, title “New appointment request”, button “Confirm Booking”), in three steps:
| Field | Name it arrives under | Required |
|---|---|---|
| Select Dental Treatment (cards of every service; on a service page only that service, already chosen) | service (the service’s title) |
yes |
| Select Preferred Expert Dentist (the dentists of the chosen treatment; every dentist until one is chosen) | dentist (the dentist’s name) |
|
| Select Date | date |
yes |
| Select Preferred Time Slot | time |
yes |
| Full Name | name |
yes |
| Phone Number | phone |
yes |
email |
yes | |
| Confirmation Contact Preference (Call, Whatsapp, Email; Call to start with) | preference |
|
| Special Notes or Dental Symptoms (Optional) | notes |
The booking form is a request, not a calendar: the date and time are what the patient asks for, and your team confirms the visit. Nothing checks your opening hours or other bookings.
The contact form on Contact (form contact, “Send a Direct Message”, title “New contact message”, button “Send
Message”): name (Full Name), phone (Phone Number), email (Email, required) and message (Message / Inquiry,
required).
The review form on Home and Services (form review, “Share Your Experience”, title “New patient review”, button
“Submit Review”): name (Full Name), email (Email), treatment (Treatment Type: the title of every service,
required), rating (Satisfaction Rating, 1 to 5 stars) and review (Your Review). A review is sent to you; it doesn’t
appear on the site by itself. To publish one, add it to src/content/collections/testimonials.json
(Editing the content).
The newsletter in the footer (form newsletter, title “New newsletter subscriber”, button “Subscribe Now”): email
(required).
A form service or webhook in static mode receives the title as subject. In server mode, Resend puts the sender’s name
after the title in the email’s subject (the title alone when there is no name) and sets the reply address to the
sender’s e-mail; Mailchimp stores the name as FNAME, tags the contact with the title and keeps the rest as a note; a
webhook receives every field of the form, as "" when left empty, with its label.
Changing the forms
Section titled “Changing the forms”The labels, placeholders, choices, the button’s three texts and the title of each submission are content:
| Form | Copy | Laid out in |
|---|---|---|
| Booking | booking in src/content/site.json |
src/components/sections/BookingForm.astro |
| Contact | form in src/content/pages/contact.json |
src/components/sections/ContactSection.astro |
| Review | testimonials.form in src/content/pages/home.json (and the same in services.json, which the Services page shows) |
src/components/sections/TestimonialsSection.astro |
| Newsletter | footer.newsletter in src/content/site.json |
src/components/site/Footer.astro |
A field arrives at your service under its name, so keep the names you already map somewhere. In server mode
src/lib/forms/definitions.ts reads the same copy to list each form’s fields and check the required ones again; it
takes the review form’s labels and title from home.json, also for the Services page.
-
To make a field required, set
"required": trueon it. The browser checks it before sending (the labels show no mark: say it in the label if you want one) and, in server mode, the route checks it again. A required field must be on the page: in server mode, a required field that is only in the list makes every submission fail. -
To add a field, add an entry (mind the comma between entries), for example an insurance provider on the contact form:
"insurance": { "name": "insurance", "label": "Insurance Provider", "placeholder": "e.g. Delta Dental" }The types are
text(the default),email,tel,url,date,time,select(withoptions) andtextarea. The fields are laid out by hand, so also place it in the form:<FormField {...fields.insurance} />in the file of the table above. -
To remove a field, delete its entry and its
<FormField … />line. -
The treatments and dentists of the booking form and the review form’s treatments come from the collections (
services.json,doctors.json): a new service or dentist appears in them by itself. Which dentists a treatment offers is the service’sdoctorslist. -
Don’t give a real field the name
fax: it is the honeypot’s (Spam).
Testing before launch
Section titled “Testing before launch”- Submit each of the four forms on your own site after deploying, with a real address: a booking from Book and one from a service page, a contact message, a review and a newsletter sign-up.
- Check the destination (inbox, spreadsheet, audience) and reply to the test.
- Try a failure on purpose: point
PUBLIC_FORM_ENDPOINTat a wrong URL in a test build (or set a wrong API key in server mode), submit, and confirm the visitor sees “Something went wrong” and their text is still there.
The honeypot stops the usual bots: every form carries a hidden field named fax that a person never sees; a bot that
fills it is shown “Thank you” and nothing is sent. If you start getting spam anyway, use a form service in static mode
(Formspree, Web3Forms and Basin all include spam filtering), or add a captcha to the form component
(src/design-system/components/forms/Form.astro).
Privacy
Section titled “Privacy”Submissions go only where you point them; nothing is sent anywhere else. A dental clinic’s forms collect health-related
details (the booking form’s symptoms, the contact form’s message), so check what the law where you practise asks of you
— in the United States, for example, HIPAA can apply to how you receive and store them — and choose a form service or
provider that meets it. The site itself stores nothing. KorDent has no consent checkbox; the footer links a Privacy
Policy, Terms of Use and an Accessibility Statement whose text (src/content/collections/legal.json) is a demo to
replace with your own, and the demo’s promises (“100% HIPAA compliant data care” in the call to action) are yours to
keep only if they are true.
Only the newsletter asks for marketing consent by its nature. If you send every form to Mailchimp in server mode, keep
MAILCHIMP_STATUS at transactional (the default): those contacts can get your replies, not your campaigns. The
provider applies to all four forms, so patients who book or write also land in the audience, tagged with the form’s
title; if you don’t want that, use another provider.