Skip to content
Sign inJoin waitlist

Forms reference — Kendi Next.js

Kendi for Next.js has two kinds of form: the newsletter sign-up, in three places — Home’s hero, the sidebar’s “Newsletter” card and the “Stay updated with our letter” band above the footer — and the Contact page’s message form. They post to the server actions subscribe and submitContact in src/lib/actions.ts.

Form Where Server action form in the payload Fields (name → label) Required
Newsletter Home hero, sidebar card, the band on most pages subscribe newsletter email Email, consent Agreed to the terms (sidebar and band) email
Contact Contact page submitContact contact Name Name, Email Email, Message Message all three
<SubscribeForm> / <Form> (design system) → subscribe / submitContact (src/lib/actions.ts) → deliver() → provider(s) chosen in FORM_PROVIDER

The form, its states, the e-mail check and the spam honeypot work out of the box. While sending, the button shows a spinner; then “Thank you” (the field is cleared) or “Something went wrong” (what was typed stays, so the visitor can try again). Where the sign-ups go is a setting, not code.

Copy .env.example to .env.local (or add the variables in your host, e.g. Vercel → Settings → Environment Variables) and set FORM_PROVIDER. Restart npm run dev after changing it.

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, your own API. FORM_WEBHOOK_URL, optional FORM_WEBHOOK_SECRET (sent as Authorization: Bearer …)
mailchimp The subscriber is added or updated in an audience, tagged with the form. MAILCHIMP_API_KEY, MAILCHIMP_AUDIENCE_ID, optional MAILCHIMP_STATUS
resend Emailed to you; replying answers the subscriber. RESEND_API_KEY, FORM_EMAIL_TO, FORM_EMAIL_FROM

Use several at once with a comma: FORM_PROVIDER=mailchimp,resend adds the subscriber to Mailchimp and emails you. If any of them fails, the visitor sees “Something went wrong” and the reason is logged on the server. Each submission carries the form’s name (form: newsletter) and its title (title: “New newsletter subscriber”).

Variable For Needed What it is
FORM_PROVIDER all no (console when missing) console, webhook, mailchimp, resend, or several, separated by commas
FORM_WEBHOOK_URL webhook yes The address that receives the POST
FORM_WEBHOOK_SECRET webhook no Sent as Authorization: Bearer <secret>; leave it empty to send no header
MAILCHIMP_API_KEY mailchimp yes Ends in your data center, e.g. …-us21
MAILCHIMP_AUDIENCE_ID mailchimp yes The audience that receives the subscribers
MAILCHIMP_STATUS mailchimp no (transactional) The status of a new contact: transactional, pending or subscribed
RESEND_API_KEY resend yes Your Resend API key
FORM_EMAIL_TO resend yes The recipient, or several separated by commas
FORM_EMAIL_FROM resend yes A sender on a domain verified in Resend, e.g. Kendi <forms@yourdomain.com>

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

  • API key: Profile → Extras → API keys. Audience ID: Audience → Settings → Audience name and defaults.
  • Consent: new contacts are added as transactional unless you set MAILCHIMP_STATUS. The forms ask people to subscribe, so use pending (double opt-in) or subscribed if Mailchimp should send them your newsletter.
{
"form": "newsletter",
"title": "New newsletter subscriber",
"submittedAt": "2026-10-27T10:48:23.256Z",
"data": { "email": "jane@example.com", "consent": "yes" },
"labels": { "email": "Email", "consent": "Agreed to the terms" }
}

The form carries a hidden text field named fax (honeypotField in src/design-system/components/forms/form-state.ts): out of sight and out of the tab order, a person never fills it, bots usually do. When it holds anything, the visitor is shown “Thank you” and nothing is sent.

subscribe checks that the e-mail looks like an address (a browser check can be bypassed), then calls deliver(data, { form, title, fields, required }) from src/lib/forms/deliver.ts, which drops honeypot submissions, reads the fields, gives the submission to every provider in FORM_PROVIDER and returns the success or error state.

4. Add your own provider (Brevo, ConvertKit, Beehiiv, a database…)

Section titled “4. Add your own provider (Brevo, ConvertKit, Beehiiv, a database…)”
  1. Create src/lib/forms/providers/<name>.ts:

    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"), 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.

The texts (placeholder, button, the success and error labels, the consent line) are in newsletter.form (and Home’s hero.subscribe) in src/content/site.ts. The Contact form’s fields (name, label, placeholder, type, required), its button and state labels and the title of its notification (“New contact message”) are in form in src/content/pages/contact.ts; submitContact follows the required flags and checks that the e-mail looks like an address. A new form: add a server action next to subscribe that calls deliver(…), and add its name to FormKind in types.ts.