Skip to content
Sign inJoin waitlist

Forms — Fitbricks Next.js

The forms of this Next.js template work as soon as you run it: the contact form, the free-trial form and the booking form of every club page.

The contact form (“Get in Touch”) is on Contact, the free-trial form (“Claim Free Trial”) on Free trial, and the booking form (“Book Your Class Now”) beside every club. 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, 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 all three forms; every submission carries the name and title of its form, 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
    Leads in a Mailchimp audience FORM_PROVIDER=mailchimp + MAILCHIMP_API_KEY, MAILCHIMP_AUDIENCE_ID; optional MAILCHIMP_STATUS (consent)
    It in a CRM, a booking tool, Slack, a spreadsheet… FORM_PROVIDER=webhook + FORM_WEBHOOK_URL (Zapier, Make, n8n, Formspree, your own API); optional FORM_WEBHOOK_SECRET

    Several at once work: FORM_PROVIDER=resend,mailchimp emails you every submission and adds the sender to Mailchimp too.

  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’s settings and how to write your own provider (HubSpot, Brevo, Airtable…) are in Forms reference.

The contact form on Contact (form: contact, title “Get in Touch”, button “Submit”):

Field Name it arrives under Required
Name Name
Email Email yes
Phone Phone
Contact Time Preferences (Morning, Afternoon, Evening, Night) Contact Time yes
Message Message

The free-trial form on Free trial (form: free-trial, title “Claim Free Trial”, button “Submit”): the same fields, plus two groups of choices before the message:

Field Name it arrives under Required
Preferred Location: every city of cities.ts City
Preferred Class: the first ten programs of programs.ts Class

The booking form on every club page (form: booking, title “Book Your Class Now”, button “Book Now”):

Field Name it arrives under Required
Name Name
Phone Phone
Email Email yes
Club Location (filled in with the club’s name) Club
Preferred Date Date
Preferred Time Time
Additional Notes Message

The e-mail is required on every form, so each provider has an address to reply to or add (the original design required only the contact time). The contact time stays required: its drop-down opens on “Anytime”, a prompt that can’t be sent, so the visitor picks a time of day. Make the name required too if you need it (below).

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 adds or updates the contact by e-mail, tags them with the title and keeps the rest as a note (an address it considers fake shows “Something went wrong”). A webhook receives every field, as "" when left empty, with its label.

The labels, placeholders, the button’s three texts and the title of each submission are content:

Form Copy Server action
Contact form in src/content/pages/contact.ts submitContact in src/lib/actions.ts
Free trial form in src/content/pages/free-trial.ts submitFreeTrial
Booking booking in src/content/pages/club.ts ({name} is the club’s name) submitBooking

A field arrives at your provider under its name, so keep the names you already map somewhere. Each server action sends every field listed in its copy 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 (and false to make it optional). The browser checks required fields before sending and the server checks them again.

  • To add a field to the contact or booking form, add an entry, for example a subject:

    { "name": "Subject", "label": "Subject", "type": "text", "placeholder": "What is it about?", "required": false },

    The types are text, email, tel, date, time, textarea and select (with options, the first being the prompt). The contact and booking forms show every field of the list in its order. The free-trial form places its fields by type (the text fields, then the choices, then the message), in src/components/sections/free-trial/FreeTrialSection.tsx.

  • To change the choices of Contact Time, edit its options (the first one is the prompt). Preferred Location lists the cities and Preferred Class the programs: change count (10) on the Class field, or the collections.

  • To remove a field, delete its entry.

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

  • Submit each form on your own site after deploying, with a real address: a contact message, a free trial and a booking from a club page.
  • Check the destination (inbox, audience, spreadsheet) and reply to the test message.
  • 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), make more fields required, or add a captcha to the form component.

Submissions go only where you point them; nothing is sent anywhere else, and the site itself stores nothing. The forms ask for names, e-mail addresses and phone numbers, so your Privacy Policy has to say how you handle them. The demo’s legal texts are samples for a made-up gym: have yours written before you collect any (Editing the content).

Mailchimp adds new contacts as transactional unless you set MAILCHIMP_STATUS: they can get your replies, not your campaigns. To send them marketing e-mails you need their consent: pending (Mailchimp emails a confirmation link first: double opt-in, the safest choice) or subscribed (only if the form asks for marketing consent, which the template’s forms don’t). The provider applies to every form, so with Mailchimp everyone who writes to you, claims a trial or books a class lands in the audience, tagged with the form’s title.