Forms reference — Denzel Next.js
Denzel for Next.js has one form: the newsletter box in the footer (“Join 89,000 subscribers!”), on every page. It posts
to the server action sendNewsletter in src/lib/actions.ts.
| Form | Where | Server action | form in the payload |
Fields (name → label) |
Required |
|---|---|---|---|---|---|
| Newsletter | every page (footer) | sendNewsletter |
newsletter |
email Email |
email |
<NewsletterForm> (design system) → sendNewsletter (src/lib/actions.ts) → deliver() → provider(s) chosen in FORM_PROVIDERThe form, its states, the e-mail check and the spam honeypot work out of the box. While sending, the button reads “…”; 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.
1. Pick a provider
Section titled “1. Pick a provider”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”).
The variables of .env.example
Section titled “The variables of .env.example”| 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. Denzel <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>".
Mailchimp notes
Section titled “Mailchimp notes”- API key: Profile → Extras → API keys. Audience ID: Audience → Settings → Audience name and defaults.
- Consent: new contacts are added as
transactionalunless you setMAILCHIMP_STATUS. The footer asks people to subscribe, so usepending(double opt-in) orsubscribedif Mailchimp should send them your newsletter.
Webhook payload
Section titled “Webhook payload”{ "form": "newsletter", "title": "New newsletter subscriber", "submittedAt": "2026-10-27T10:48:23.256Z", "data": { "email": "jane@example.com" }, "labels": { "email": "Email" }}2. Spam: the honeypot
Section titled “2. Spam: the honeypot”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.
3. The server action
Section titled “3. The server action”sendNewsletter 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…)”-
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()}`);},}; -
Register it in
providers/index.ts(brevo: brevoProvider). -
Set
FORM_PROVIDER=brevoand its variables in.env.example/ your host.
5. Change the form
Section titled “5. Change the form”The texts (title, line, placeholder, button, the success and error labels, the note) are in footer.newsletter in
src/content/site.ts. A new form: add a server action next to sendNewsletter that calls deliver(…), and add its name
to FormKind in types.ts.