Forms — Semono Astro
The three forms of this Astro template work as soon as you run it: a Contact inquiry, a service consultation and a career application.
The inquiry is on the Contact page, a consultation form on every service page and an application form on every career 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 three 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 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 three forms post to the same endpoint, with form (contact, consultation or application) 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_IDThe 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/contact,/api/forms/consultationand/api/forms/application(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 inquiry on the Contact page (form contact, title “New contact inquiry”):
| Field | Name it arrives under | Required |
|---|---|---|
| Full Name | name |
yes |
| Business Email | email |
yes |
| Phone Number | phone |
|
| Company Name | company |
|
| Service Required (Business Strategy, Operational Consulting, Leadership Advisory, Corporate Transformation, Financial Advisory, Brand & Market Consulting, Process Optimization, Organizational Growth) | service |
yes |
| Project Budget (Under $5,000, $5,000 — $10,000, $10,000 — $25,000, $25,000+) | budget |
yes |
| Project Details | details |
The consultation form on every service page, after the overview (form consultation, button “Book a free
consultation”, title “New consultation request”): name (Full Name, required), email (Business Email, required),
phone (Phone Number), company (Company Name), service (Service Required: a text field that starts with the page’s
own service, so a visitor on “Business Strategy” sends “Business Strategy”) and details (Project Details).
The application form on every career page, in the white card (form application, button “Submit application”,
title “New job application”):
| Field | Name it arrives under | Required |
|---|---|---|
| Name | name |
yes |
email |
yes | |
| Phone | phone |
|
| Job Position (starts with the page’s own position) | position |
|
| LinkedIn URL | linkedin |
|
| Cover letter | letter |
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 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, the choices of the selects, the button’s three texts (the inquiry’s are “Send inquiry”,
“Thank you” and “Something went wrong”) and the title of each submission (notification) are content: contactForm in
src/content/pages/contact.json, consultationForm in src/content/pages/service.json and careerForm in
src/content/pages/career.json. A field arrives at your service under its name, so keep the names you already map
somewhere. The Contact form’s service choices are typed there; they include two that are not services of the collection
(“Process Optimization”, “Organizational Growth”): make the list match your own services.
Each form sends every field it shows, and in server mode src/lib/forms/definitions.ts reads the same lists to check
the required ones again, so the list in the copy is the place to edit:
-
To make a field required, set
"required": trueon it. Its label gets a red asterisk, the browser checks it before sending 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 a website:
"website": { "name": "website", "label": "Website", "placeholder": "https://", "type": "url", "autoComplete": "url" }The types are
text(the default),email,tel,url,select(withoptions; the placeholder is its empty first choice) andtextarea. On the career pages the field then appears by itself, in the order of the list (aurlortextareafield across both columns). On the Contact page and on the service pages the fields are laid out by hand, so also place it in the form:<FormField {...fields.website} />insrc/components/sections/ContactSection.astroorsrc/components/sections/ServiceActionSection.astro(addclass="md:col-span-2"for a full-width one). -
To remove a field, delete its entry, and on the Contact and service pages its
<FormField … />line. -
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 three forms on your own site after deploying, with a real address: one inquiry, one consultation request from a service page and one application from a career page.
- 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. Most countries expect you to say what happens
to the data people send you, and the application form collects a name, an e-mail, a LinkedIn address and a cover
letter. Semono has no consent checkbox. The footer links a Privacy Policy and Terms of Service whose text
(src/content/collections/legal.json) is a demo to replace with your own.
The forms don’t ask for marketing consent, so if you send them to Mailchimp, keep MAILCHIMP_STATUS at transactional
(the default): those contacts can get your replies, not your campaigns. The provider applies to all three forms, so job
applicants land in the audience too, tagged “New job application”; if you don’t want that, use another provider.