Skip to content
Sign inJoin waitlist

Forms reference — Goeboek Astro

Goeboek for Astro has three forms (Form.astro): Contact (the Contact page, form contact), “Schedule tour” (every property page, form tour) and Add property (the Add property page, form property). They work in one of three ways, chosen with environment variables (copy .env.example to .env, or set them in your host’s dashboard); no code changes.

Form Where form in the payload Fields (name → label) Required
Contact Contact page contact name Name, email Email, message Message name, email
Schedule tour every property page tour propertyId Property ID, propertyName Property Name (both filled in from the property), name, email, phone, message all but message
Add property Add property page property name, email, phone, propertyName, location and category (radios), for (Sell / Rent), price, duration (/Days, /Months, /Years), size, bedrooms, bathrooms, floor, additionalSpace, furnishing, ceilingHeight, constructionYear, renovation (dates as YYYY-MM-DD), heating, airCondition, fireplace, elevator, ventilation, intercom, windowType, cableTv, wifi, message the personal fields, propertyName, for, price, duration and the details but renovation
Mode Set Hosting Where submissions go
Demo (default) nothing any static host Nowhere: the button shows “Thank you” and the fields are logged in the browser console.
Static PUBLIC_FORM_ENDPOINT any static host Posted from the browser to a form service or webhook.
Server PUBLIC_FORM_MODE=server + FORM_PROVIDER a host with an Astro adapter Delivered by the site’s own route to console, webhook, Mailchimp or Resend.

Every mode shows the same states on the button (a spinner while sending, then “Thank you” or “Something went wrong”) and drops spam caught by the hidden honeypot field (fax). Each form checks its fields first (the first empty or invalid one gets the focus), keeps what was typed on an error, and on success either resets (Contact) or opens its thank-you page — the tour form /success-scheduled, Add property /success-add-property, as Framer does. The PUBLIC_ variables are read when the site is built: rebuild (or restart npm run dev) after changing them.

<Form> → browser: PUBLIC_FORM_ENDPOINT, or the demo
→ server mode: POST /api/forms/<form> → deliver() → provider(s) chosen in FORM_PROVIDER

formEndpoint("contact"), formEndpoint("tour") and formEndpoint("property") in src/lib/forms/endpoint.ts decide where a form posts: /api/forms/<form> in server mode, else PUBLIC_FORM_ENDPOINT, else nothing (demo mode). The browser part is src/design-system/scripts/form.ts; the forms’ definitions (fields, labels, required) are in src/lib/forms/definitions.ts, read from the page copy (src/content/pages/contact.json, property.json → tour, add-property.json → form).

1. Static mode: form services and webhooks

Section titled “1. Static mode: form services and webhooks”

Set PUBLIC_FORM_ENDPOINT to the URL the service gives you. The form posts multipart/form-data with Accept: application/json; the service must answer with a 2xx status, anything else shows “Something went wrong”.

Service PUBLIC_FORM_ENDPOINT Notes
Formspree https://formspree.io/f/<form id> Emails you each submission.
Web3Forms https://api.web3forms.com/submit Also set PUBLIC_FORM_ACCESS_KEY (sent as the hidden field access_key).
Getform, Basin the form’s endpoint URL
Zapier, Make, n8n, Pipedream the webhook (“catch hook”) URL Route submissions anywhere: Mailchimp, Google Sheets, Slack, a CRM.

Fields sent: the fields above, plus form (contact, tour or property) and subject (the form’s title: “New contact enquiry”, “New tour request”, “New property submission”). All three forms post to the same endpoint; tell them apart by form.

  1. Add the adapter for your host: npx astro add vercel (or netlify, node, …).
  2. Set PUBLIC_FORM_MODE=server and choose providers with FORM_PROVIDER.

The forms then post to POST /api/forms/contact, /api/forms/tour and /api/forms/property (src/lib/forms/route.ts, added by src/integrations/forms.ts; every other page stays prerendered). Without an adapter the build stops with NoAdapterInstalled. Astro rejects cross-site posts to the route. The route answers JSON: 200 { "status": "success" }, or 500 { "status": "error" } (404 unknown form, 400 not form data).

FORM_PROVIDER What happens Variables
console (default) Printed to the server log. For development. —
webhook Posted as JSON to a URL — Zapier, Make, n8n, Pipedream, Formspree, your own API. FORM_WEBHOOK_URL, optional FORM_WEBHOOK_SECRET (sent as Authorization: Bearer …)
mailchimp Sender added or updated in an audience (name → FNAME, phone → PHONE), tagged with the form, the rest saved as a note. MAILCHIMP_API_KEY, MAILCHIMP_AUDIENCE_ID, optional MAILCHIMP_STATUS
resend Emailed to you; replying answers the sender. RESEND_API_KEY, FORM_EMAIL_TO, FORM_EMAIL_FROM

Use several with a comma (FORM_PROVIDER=resend,mailchimp). If one fails the visitor sees the error state and the reason is logged on the server. A provider that needs a variable and doesn’t find it stops the submission with Missing environment variable <NAME> (see .env.example). Add your own provider in src/lib/forms/providers/index.ts.