Skip to content
Sign inJoin waitlist

Forms — Marai Neesu Next.js

The two forms of this Next.js template work as soon as you run it: the inquiry on the Contact page and the newsletter sign-up on the Blog page.

Each form checks the required fields, shows a spinner on its 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. Without JavaScript the browser still posts them to the server.

Out of the box, submissions are written to the server log (FORM_PROVIDER=console). That’s fine while you build, but useless once you publish, so pick a destination before launch. One provider serves both forms; every submission carries the title of its form (“New contact inquiry”, “New newsletter subscriber”), so you can tell them apart in your inbox or tool.

  1. Copy the example settings:

    Terminal window
    cp .env.example .env.local
  2. Choose one:

    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)
    The sender in a Mailchimp audience (the natural home of newsletter subscribers) FORM_PROVIDER=mailchimp + MAILCHIMP_API_KEY, MAILCHIMP_AUDIENCE_ID

    Several at once work: FORM_PROVIDER=resend,mailchimp.

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

  4. Put the same variables in your host’s dashboard before deploying. .env.local is not uploaded.

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 inquiry on the Contact page (button “Send message”, title “New contact inquiry”):

Field Name it arrives under Required
First Name firstName yes
Last Name lastName yes
Email email yes
Phone Number phone yes
I’m interested in … (a checkbox for each service: Product Design, Web Design, Mobile App Design, User Experience (UX) Design) interests (a list)
Project Budget (USD) budget yes
Message message

The newsletter on the Blog page, in the box under the posts (button “Subscribe”, title “New newsletter subscriber”): one field, Email (email, required).

The required fields are the original design’s, except the newsletter’s e-mail, which the original lets through empty. As on the original, the fields show no asterisk: the browser names a missing field when the visitor sends.

Resend puts the sender’s name (the first and last name) after the title in the email’s subject and sets the reply address to the sender’s e-mail. Mailchimp stores the names as FNAME and LNAME, tags the contact with the title and each service ticked, and keeps the rest as a note; a newsletter subscriber is added as pending (Mailchimp sends a confirmation email) unless you set MAILCHIMP_NEWSLETTER_STATUS=subscribed. A webhook receives every field of the form, as "" when left empty (the services as a list), with its label.

The labels, placeholders, the button’s three texts (“Send message”, “Thank you”, “Something went wrong”) and the title of each submission (notification) are content: contactForm in src/content/pages/contact.ts and newsletter.form in src/content/pages/blog.ts. A field arrives at your provider under its name, so keep the names you already map somewhere. The “I’m interested in” choices are not typed anywhere: they are the titles of the services in src/content/collections/services.ts, so they follow your services.

The server action of each form (submitContact in src/lib/actions-contact.ts and submitNewsletter in src/lib/actions-newsletter.ts) sends every field listed in its form and checks the required ones again on the server, so the list in the copy is the place to edit:

  • To make a field required, set required: true on it; to make it optional, remove it. The browser checks it before sending and the server checks it again. A required field must be on the page: if it is only in the list, every submission fails.

  • To add a field, add an entry, for example a website:

    website: { name: "website", label: "Website", placeholder: "https://", type: "url", autoComplete: "url" },

    The types are text (the default), email, tel, url, textarea and checkboxes. The fields are laid out by hand, so also place it in the form: pass it from src/app/contact/page.tsx (website: toField(fields.website)) and add "website" to the field names of fields and <FormField {...fields.website} /> in src/components/sections/ContactSection.tsx.

  • To remove a field, delete its entry, its line in src/app/contact/page.tsx, and its name and its <FormField … /> line in ContactSection.tsx.

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

  • Submit both forms on your own site after deploying, with a real address: one inquiry from the Contact page and one sign-up from the Blog.
  • Check the destination (inbox, spreadsheet, audience) and reply to the test.
  • Try a failure on purpose: set a wrong API key, 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, put a service in front through the webhook provider (Formspree, Web3Forms and Basin all include spam filtering), or add a captcha to the form component.

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: the inquiry collects a name, an e-mail, a phone number and a budget, the newsletter an e-mail. Marai Neesu has no consent checkbox and no privacy page: add one if your visitors need it (Pages and sections).

The inquiry 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. Newsletter subscribers confirm by e-mail while MAILCHIMP_NEWSLETTER_STATUS stays at pending (the default).