Skip to content
Sign inJoin waitlist

Forms — Goeboek Astro

The three forms of this Astro template work as soon as you run it: the contact form on the Contact page, “Schedule tour” on every property page and the form on the Add property page.

All three check their fields in the browser (the first empty or wrong one gets the focus), show a spinner on the button while sending, then “Thank you” or “Something went wrong”, and drop spam with a hidden honeypot field. On success the contact form clears its fields and stays on the page; “Schedule tour” opens /success-scheduled and Add property opens /success-add-property, as in the original design. On an error every form keeps what the visitor typed.

Out of the box they run in demo mode: nothing is sent, and the fields are logged in the browser console (the tour and Add property forms still open their thank-you pages). That’s fine while you build, but useless once you publish, so pick a destination before launch.

You want Mode Hosting
An email for every message, tour request and listing, with no server to run Static: a form service (Formspree, Web3Forms, Getform, Basin) Any static host
Them in a CRM, a spreadsheet, Slack… 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.

  1. Create a form at your service and copy its endpoint URL (Formspree: https://formspree.io/f/<id>).

  2. Copy the example settings and paste the URL:

    Terminal window
    cp .env.example .env
    PUBLIC_FORM_ENDPOINT=https://formspree.io/f/abcdwxyz

    Web3Forms also needs PUBLIC_FORM_ACCESS_KEY.

  3. Restart npm run dev and send a test from each form.

  4. If your host builds the site, put the same variable in its dashboard before deploying: .env stays on your computer (it is not in Git). The value is written into the pages when the site builds, so rebuild after changing it.

All three forms post to the same endpoint; the hidden form field (contact, tour or property) tells them apart, and subject (“New contact enquiry”, “New tour request”, “New property submission”) becomes the email’s subject at the services that email you. The endpoint is public (it is in the page), which is how these services are designed to work; they filter spam on their side. The forms post multipart/form-data and expect a 2xx answer. Details for each service are in Forms reference.

For Resend or Mailchimp without a third-party service, the forms post to a route on your own site:

  1. Add the adapter for your host: npx astro add vercel (or netlify, node, …).

  2. Set PUBLIC_FORM_MODE=server, and choose where submissions go with FORM_PROVIDER:

    You want Set
    An email for every submission FORM_PROVIDER=resend + RESEND_API_KEY, FORM_EMAIL_TO, FORM_EMAIL_FROM
    The senders in a Mailchimp audience FORM_PROVIDER=mailchimp + MAILCHIMP_API_KEY, MAILCHIMP_AUDIENCE_ID; MAILCHIMP_STATUS is optional (below)
    It in your CRM, Slack, a spreadsheet… FORM_PROVIDER=webhook + FORM_WEBHOOK_URL; FORM_WEBHOOK_SECRET is optional
    The server log only, while you test FORM_PROVIDER=console (the default)

    Several at once work: FORM_PROVIDER=resend,mailchimp. The setting applies to all three forms.

  3. Restart npm run dev and send a test. The forms now post to /api/forms/contact, /api/forms/tour and /api/forms/property (src/lib/forms/route.ts, added by src/integrations/forms.ts); every page stays static, only that route runs on the server, and it checks the required fields again.

  4. Put the same variables in your host’s dashboard before deploying, and redeploy after changing them.

Without an adapter, the build stops with NoAdapterInstalled. Details for each provider, what it receives and how to write your own provider are in Forms reference.

The contact form (form contact, title “New contact enquiry”):

Field Name it arrives under Required
Name name yes
E-mail email yes, and it must look like an e-mail address
Message message no

“Schedule tour” (form tour, title “New tour request”):

Field Name it arrives under Required
Property ID (filled in from the property) propertyId yes
Property Name (filled in from the property) propertyName yes
Name name yes
E-mail email yes, and it must look like an e-mail address
Phone phone yes
Message message no

Add property (form property, title “New property submission”), in the order of the page:

Group Fields (name it arrives under) Required
Personal Information name, email, phone all
Property Description propertyName; location and category (radio buttons: Brooklyn, Manhattan, Queens, Staten Island, The Bronx; Apartments, Condos, Houses, Villas); for (Sell or Rent); price (a number); duration (/Days, /Months or /Years) propertyName, for, price, duration
Property Details size (m2), bedrooms, bathrooms, floor, additionalSpace, furnishing, ceilingHeight (m), constructionYear, renovation (dates as YYYY-MM-DD) all but renovation
Property Utility heating, airCondition, fireplace, elevator, ventilation, intercom, windowType, cableTv, wifi (Yes / No, or text for heating and window type) none
Message message no

A field left empty arrives as "" (a radio group nobody picked, a select left on “Select…”). In server mode, Resend sends the title followed by the sender’s name as the email’s subject (“New tour request — Jane Smith”), lists every filled field as “Label: value” and sets the reply address to the one typed in the form; Mailchimp adds or updates the sender in your audience (name → FNAME, phone → PHONE), tags them with the title and keeps the submission as a note; a webhook receives { form, title, submittedAt, data, labels } as JSON.

MAILCHIMP_STATUS decides what you may send to the people the forms add: transactional (the default) stores the contact but they can’t receive your campaigns, pending sends them a confirmation e-mail first (double opt-in), and subscribed is only for addresses that gave explicit consent. None of the three forms asks for marketing consent, so keep transactional unless you add a consent checkbox. To change which fields fill the audience’s merge fields, edit mergeFields in src/lib/forms/providers/mailchimp.ts (field names are matched ignoring case).

The words and fields are in the page copy:

  • the contact form: form in src/content/pages/contact.json (its title, the name, email and message fields, the button’s three texts and the notification title);
  • “Schedule tour”: tour in src/content/pages/property.json (the title, the text, the six fields, the button’s texts, redirect: /success-scheduled, and the notification title);
  • Add property: form in src/content/pages/add-property.json (the five groups and their fields, the button’s texts, redirect: /success-add-property, and the notification title).

Each field has a name (what you receive), a label (what people read above it, and what the notifications show), a placeholder, a type (text, email, tel, number, date; radio with options for Location and Category; a field with options alone is a select) and required. The browser and the server route read the same flags (src/lib/forms/definitions.ts), so a field you make optional or required there is checked that way. Change redirect to send a form to another page once sent; remove it to stay on the page with “Thank you” on the button.

A new field goes in the copy, then into the form’s section (src/components/sections/ContactDetails.astro, TourForm.astro or AddPropertyForm.astro) and into its list in src/lib/forms/definitions.ts, so it is placed and delivered. The form itself is src/design-system/components/forms/Form.astro, and its script src/design-system/scripts/form.ts. Keep a field named email in every form: Resend and Mailchimp use it.

  • Send each of the three forms from your own site after deploying, with a real address.
  • Check the destination (inbox, spreadsheet, audience), and that the tour request names its property.
  • Try a failure on purpose: point PUBLIC_FORM_ENDPOINT at a wrong URL in a test build (or set a wrong API key in server mode), submit, and confirm the button says “Something went wrong” and the form still holds what was typed.

The honeypot stops the usual bots: each 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).

Messages, tour requests and listings go only where you point them; nothing is sent anywhere else. The forms collect names, e-mail addresses, phone numbers and details of people’s property: say what happens to them in your privacy policy, and choose a form service or provider that keeps the data where the law where you work allows. The template has no privacy page and no consent checkbox: add them if your visitors’ country requires it (Pages and sections).