Skip to content
Sign inJoin waitlist

Forms reference — Marai Neesu Astro

The two forms of Marai Neesu for Astro (the inquiry on the Contact page and the newsletter on the Blog page) share one pipeline and work in one of three ways. You choose with environment variables (copy .env.example to .env, or set them in your host’s dashboard); no code changes.

Form Where name of the <Form> / form in the payload Fields (name → label)
Inquiry Contact page contact firstName First Name, lastName Last Name, email Email, phone Phone Number, interests I’m interested in … (a list), budget Project Budget (USD), message Message
Newsletter Blog page newsletter email Email (required; Framer’s isn’t)

The options of interests are the titles of the services (src/content/collections/services.json): add, rename or remove a service and the checkboxes follow.

Mode Set Hosting Where submissions go
Demo (default) nothing any static host Nowhere: the form shows “Thank you” and logs the fields 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 Submit button (spinner, “Thank you”, “Something went wrong”), keeps the typed values after an error, resets the form after success and drops spam caught by the hidden honeypot field.

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

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, and the service must answer with a 2xx status.

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.
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: every input by its name (see the table above) plus form (contact or newsletter) and subject (the form’s notification title). One endpoint receives both forms: tell them apart by form.

The endpoint is public (it is in the page), which is how these services are designed to work; they filter spam themselves. A build with PUBLIC_FORM_ENDPOINT set sends the style guide’s sample forms nowhere: they are marked demo.

For Mailchimp or Resend without a third-party service, run the forms on your server:

  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/<form> (src/lib/forms/route.ts, added by src/integrations/forms.ts). Without an adapter the build stops with NoAdapterInstalled. Astro rejects cross-site posts to the route, so only your own pages can submit. Environment variables are read when the server runs (process.env, then the values of the build); a variable left empty counts as unset, so a blank MAILCHIMP_NEWSLETTER_STATUS= keeps its default. Restart astro dev after changing .env.

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, Slack workflow, your own API. FORM_WEBHOOK_URL, optional FORM_WEBHOOK_SECRET (sent as Authorization: Bearer …)
mailchimp Sender added or updated in an audience, tagged with the form and the services they picked, the rest saved as a note. MAILCHIMP_API_KEY, MAILCHIMP_AUDIENCE_ID, optional MAILCHIMP_STATUS, MAILCHIMP_NEWSLETTER_STATUS
resend Emailed to you; replying answers the sender. RESEND_API_KEY, FORM_EMAIL_TO, FORM_EMAIL_FROM

Use several at once with a comma: FORM_PROVIDER=resend,mailchimp emails you and adds the contact to Mailchimp. If any of them fails, the visitor sees “Something went wrong” (their input stays in the form) and the reason is logged on the server. The providers run at the same time, so when one fails the others have usually delivered already: sending again can duplicate. The provider applies to both forms; each submission says which form it came from (form, and the title).

A provider that needs a variable and doesn’t find it stops that submission with Missing environment variable <NAME> (see .env.example) in the server log; a name in FORM_PROVIDER that doesn’t exist does the same with Unknown FORM_PROVIDER "<name>". The visitor sees “Something went wrong” in both cases.

  • console: [forms] <title> followed by the submitted values (data) as an object.
  • webhook: one POST of JSON (Content-Type: application/json) holding the whole submission, as in the payload below. An answer that isn’t a success is an error.
  • mailchimp: three calls. The sender is added or updated in the audience (email, in lower case, and FNAME / LNAME from firstName / lastName; MAILCHIMP_STATUS — MAILCHIMP_NEWSLETTER_STATUS for the newsletter, pending by default — is the status of a new contact only), tagged with the form’s title and the services ticked under interests, and a note is added to the profile: the title, then one “Label: value” line for each field that was filled in.
  • resend: one e-mail from FORM_EMAIL_FROM to FORM_EMAIL_TO. The subject is the title followed by the sender’s name (firstName and lastName: “New contact inquiry — Jane Smith”; the title alone if the name is empty), the reply address is the sender’s e-mail, and the text is one “Label: value” line for each field that was filled in, then the time it was sent.
  • API key: Profile → Extras → API keys. It ends in your data center (…-us21); nothing else to configure.
  • Audience ID: Audience → Settings → Audience name and defaults.
  • Consent: new contacts are added as transactional — they can receive replies, not campaigns. Use pending to send a double opt-in email, or subscribed only if the form asks for marketing consent. The inquiry doesn’t; the newsletter is a sign-up, so it asks for a double opt-in (pending) by default.
  • Merge fields: firstName → FNAME, lastName → LNAME (a new audience’s defaults). Change mergeFields at the top of providers/mailchimp.ts if your audience uses other tags, for example phone: "PHONE".
{
"form": "contact",
"title": "New contact inquiry",
"submittedAt": "2026-10-07T10:48:23.256Z",
"data": {
"firstName": "Jane", "lastName": "Smith", "email": "jane@example.com", "phone": "",
"interests": ["Web Design", "UX Design"], "budget": "5000", "message": "We need a new website."
},
"labels": {
"firstName": "First Name", "lastName": "Last Name", "email": "Email", "phone": "Phone Number",
"interests": "I'm interested in ...", "budget": "Project Budget (USD)", "message": "Message"
}
}

data has a key for every field of that form (the names in the table above), as "" when left empty, and labels the label of each, in the order of the form.

Every form carries a hidden text field named fax (honeypotField in src/design-system/components/forms/form-state.ts): it is out of sight and out of the tab order, a person never fills it, and bots usually do. The form shows “Thank you” without sending anything when it holds anything (and deliver() does the same on the server), so the bot moves on. Keep it as it is, and don’t give a real field the name fax.

4. Your own provider (HubSpot, Brevo, Airtable, a database…)

Section titled “4. Your own provider (HubSpot, Brevo, Airtable, a database…)”
  1. Create src/lib/forms/providers/<name>.ts exporting a FormProvider — throw to show the error state:

    import { env, valueOf, type FormProvider } from "../types";
    export const brevoProvider: FormProvider = {
    name: "brevo",
    async send(submission) {
    const response = await fetch("https://api.brevo.com/v3/contacts", {
    method: "POST",
    headers: { "api-key": env("BREVO_API_KEY"), "Content-Type": "application/json" },
    body: JSON.stringify({
    email: valueOf(submission, "email"),
    attributes: { FIRSTNAME: valueOf(submission, "firstName") },
    updateEnabled: true,
    }),
    });
    if (!response.ok) throw new Error(`Brevo responded ${response.status}: ${await response.text()}`);
    },
    };
  2. Register it in providers/index.ts (brevo: brevoProvider).

  3. Set FORM_PROVIDER=brevo and its variables in .env.example / your host.

Helpers from types.ts: valueOf(submission, name) returns one field as text, toLines(submission) returns "Label: value" lines for every filled field, and env(name) reads a required variable with a clear error. senderName(submission) is the sender’s name. Both forms have the field email, so a provider that needs a person can rely on it.

  • Fields and labels live in the copy: contactForm in src/content/pages/contact.json, newsletter.form in src/content/pages/blog.json. name is the key services and providers receive, label is what people read, required adds the browser’s check, type: "checkboxes" makes a group of options. The button’s three texts and the title of the notification are there too.
  • Required fields come from the same required flags: in server mode src/lib/forms/definitions.ts checks them again before it sends anything.
  • A new field: add it to the list in the copy and lay it out in src/components/sections/ContactSection.astro (or NewsletterSection.astro) with <FormField {...fields.<name>} />.
  • A new form: lay it out with <Form name="…"> and <FormField>, give the endpoint with formEndpoint("…") (src/lib/forms/endpoint.ts), add its definition to definitions.ts for server mode and its name to FormKind in types.ts.