Forms — Lookis Next.js
The contact form of this Next.js template works as soon as you run it: the inquiry on the Contact page, under “Let’s Connect”.
It 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. It works without JavaScript too.
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.
The quickest way to receive submissions
Section titled “The quickest way to receive submissions”-
Copy the example settings:
Terminal window cp .env.example .env.local -
Choose one:
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)The sender in a Mailchimp audience FORM_PROVIDER=mailchimp+MAILCHIMP_API_KEY,MAILCHIMP_AUDIENCE_IDSeveral at once work:
FORM_PROVIDER=resend,mailchimp. -
Restart
npm run devand send a test from the Contact page. -
Put the same variables in your host’s dashboard before deploying.
.env.localis 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.
What the form asks for
Section titled “What the form asks for”The inquiry on the Contact page (title “New message from the Lookis contact form”):
| Field | Name it arrives under | Required |
|---|---|---|
| Name (“Your Name”) | name |
|
| Email (“Your Email”) | email |
yes |
| Message (“Your Message”) | message |
yes |
The fields show placeholders only, as in the original design; each is named for screen readers by its label. Name and Email sit side by side (one under the other on phones), the message under them, then the Submit button across.
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 form
Section titled “Changing the form”The labels, placeholders, the button’s three texts (“Submit”, “Thank you”, “Something went wrong”) and the title of each
submission are content: contactForm in src/content/pages/contact.ts. A field arrives at your provider under its
name, so keep the names you already map somewhere. The title of the card around the form, “Let’s Connect”, is
formTitle in the same file.
The server action (submitContact in src/lib/actions-contact.ts) sends every field listed in contactForm.fields
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: trueon 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 phone number:
phone: { name: "phone", label: "Phone", placeholder: "Your Phone", type: "tel", autoComplete: "tel" },The types are
text(the default),email,tel,url,select(withoptions; the placeholder is its empty first choice) andtextarea. The fields are laid out by hand, so also place it in the form:<FieldControl {...form.fields.phone} />insrc/components/sections/ContactSection.tsx(addclassName="md:col-span-2"for a full-width one). For a field with a visible label, use<FormField>instead. -
To remove a field, delete its entry and its
<FieldControl … />line (the component picks the fields by name at its top:const { name, email, message } = form.fields). -
Don’t give a real field the name
fax: it is the honeypot’s (Spam).
Testing before launch
Section titled “Testing before launch”- 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: 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: 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, 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.
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 form collects a name, an e-mail address and a message. Lookis has no consent checkbox and no privacy page: add one if your visitors’ country requires it (Pages and sections).
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.