Skip to content
Sign inJoin waitlist

Forms — Lookis Astro

The contact form of this Astro template works as soon as you run it: Name, Email and Message, on the Contact page.

It checks the required fields (Email and Message), shows a spinner on its Submit button 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 it runs 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.

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.

  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 the Contact page.

  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.

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 form posts its fields with form (contact) and subject (the submission’s title, “New message from the Lookis contact form” in the demo) next to them. Details for each service are in Forms reference.

For Resend or Mailchimp without a third-party service, the form posts 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
    It in your CRM, Slack, a spreadsheet… FORM_PROVIDER=webhook + FORM_WEBHOOK_URL (Zapier, Make, n8n, Formspree, your own API); FORM_WEBHOOK_SECRET is optional
    The sender in a Mailchimp audience FORM_PROVIDER=mailchimp + MAILCHIMP_API_KEY, MAILCHIMP_AUDIENCE_ID
    The server log only, while you test FORM_PROVIDER=console (the default)

    Several at once work: FORM_PROVIDER=resend,mailchimp.

  3. Restart npm run dev and send a test. The form now posts to /api/forms/contact (src/lib/forms/route.ts, added by src/integrations/forms.ts); every page stays static, only that route runs on the server.

  4. 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.

The contact form on the Contact page (form contact, button “Submit”, title “New message from the Lookis contact form”):

Field Name it arrives under Required
Name name
Email email yes
Message message yes

The fields show placeholders (“Your Name”, “Your Email”, “Your Message”) and no visible labels, as in the original design; each is named for screen readers with its label. 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.

The labels, placeholders, the button’s three texts (“Submit”, “Thank you” and “Something went wrong”), the title of the form card (“Let’s Connect”, contact.formTitle) and the title of each submission (notification) are content: contactForm in src/content/pages/contact.json. A field arrives at your service under its name, so keep the names you already map somewhere. Write your own notification: the demo’s names the template.

The form sends every field it shows, and in server mode src/lib/forms/definitions.ts reads the same list to check the required ones again, so the list in the copy is the place to edit:

  • To make a field required, set "required": true on it (to make the name required, for example). 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 phone number:

    "phone": { "name": "phone", "label": "Phone", "placeholder": "Your Phone", "type": "tel", "autoComplete": "tel" }

    The types are text (the default), email, tel, url, select (with options; the placeholder is its empty first choice) and textarea. The fields are laid out by hand, so also place it in the form, in src/components/sections/ContactSection.astro: take it from form.fields next to name, email and message, and add <FieldControl {...phone} /> where it should go (with class="md:col-span-2" for a full-width one; Name and Email sit side by side from tablets up).

  • To remove a field, delete its entry and its <FieldControl … /> line. Keep email: Resend and Mailchimp use it.

  • Don’t give a real field the name fax: it is the honeypot’s (Spam).

  • Submit the form on your own site after deploying, with a real address.
  • Check the destination (inbox, spreadsheet, audience) and reply to the test.
  • 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 visitor sees “Something went wrong” and their text is still there.

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

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 form collects a name, an e-mail address and a message. Lookis has no consent checkbox and no privacy page: add one (see adding a page) if the law where you work asks for it, and link it from the footer.

The form doesn’t ask for marketing consent, so if you send it to Mailchimp, keep MAILCHIMP_STATUS at transactional (the default): those contacts can get your replies, not your campaigns.