Skip to content

Building blocks

Contact

/contact lets visitors reach you without the address appearing in the page. It offers a form that mails your hello mailbox their message, a "Show email address" button that hands out the address after a Turnstile check, or both. You work here when you set the address for a deploy, choose what the page offers, name an address in a page or change how it looks.

How it works

  1. The address is mailboxes.hello on the site's domain, such as hello@example.com (Configuration). NUXT_CONTACT_ADDRESS replaces it when set, through contactAddress, a private runtime-config key. Only the two routes below read the address, at request time, so /contact's HTML never carries it, and no build, page, payload or bundle carries NUXT_CONTACT_ADDRESS.
  2. layers/kit/modules/contact-routes.ts(Licensees only) registers one route per entry in contact.channels: POST /api/contact for form and POST /api/contact/address for reveal. A channel left out answers 404.
  3. Each route counts the attempt against the caller's IP, then checks that the address is set and that Turnstile passes. The form sends the message through deliverEmail with the sender as Reply-To, once, while the request lasts: it is never queued or stored. The reveal answers { address } with cache-control: no-store.
  4. The kit's support links (SupportLink and the footers) take their path from useContactPath(), which is null while contact.enabled is false, so they render nothing then. :contact-line in the legal pages names a mailbox instead (Name an address in a page).

Choose the channels

contact: {
  enabled: true,
  channels: ['form', 'reveal'],
},
channelsThe page shows
['form', 'reveal']The form, with "Prefer to write directly? Show email address" below
['form']The form alone
['reveal']"Show email address" as the page's only button

enabled: false drops the kit's page and both routes from the build. A page of yours at /contact stays (Change the page). The build refuses an empty channels, a channel it doesn't know, and form while email.enabled is false.

Set the address

A deploy on example.com mails and shows hello@example.com with nothing to set. Create that mailbox before the first deploy (Deployment). While the mailboxes have no domain, as on *.workers.dev without mailboxes.domain, both routes answer 503. The [env] line a deployed Worker logs at boot names everything the page still lacks: a mailbox domain, the Turnstile keys and, with form, a configured email provider (Email).

Under pnpm dev, localhost gives the mailboxes no domain, so both routes answer 503 until you set NUXT_CONTACT_ADDRESS in .env. The form then prints each message to the terminal like any other mail.

hello@ is public: every mail is sent from it and replies to it, and /.well-known/security.txt names it. The reveal keeps it out of /contact's HTML and no further. To keep the contact address private, set another one on the Worker:

pnpm exec wrangler secret put NUXT_CONTACT_ADDRESS --name <worker>

It wins over hello@, and the boot check names it as long as it differs. Keep it off NUXT_EMAIL_FROM and NUXT_EMAIL_REPLY_TO: every mail the app sends carries both, and anyone can ask for a sign-in mail to their own inbox.

Turnstile

Both routes call assertHuman (Auth) before they send or answer. Outside pnpm dev, the contact routes answer 503 while the Turnstile keys are unset, where the auth forms would skip the check. pnpm dev runs on Cloudflare's always-pass test keys.

Limits

WhatLimit
Attempts per IP address5 in 10 minutes on each route, then locked for 10 minutes. IPv6 by /64.
Messages, site-wide30 an hour, counted once Turnstile passes
Name1 to 100 characters, on one line
EmailUp to 254 characters
Message10 to 5,000 characters, with no control characters but tabs and newlines

Over a limit the route answers 429 with Retry-After (Rate limiting). A message every provider refuses answers 502 and is not retried; the form keeps it so the visitor can send it again. The numbers live in layers/kit/server/contact/limits.ts(Licensees only) and layers/kit/shared/schemas/contact.ts(Licensees only).

What you receive

A mail in plain text from the app's sender, hello@ unless NUXT_EMAIL_FROM says otherwise (Email), with the subject "Contact from" and the sender's name, and the sender's address as Reply-To. Its first line names the signed-in account that sent it, marked when that account hasn't proven its address yet, or says it was sent signed out. The name and Reply-To are marked unverified, because anyone can type any address: confirm a request about an account with that account's address before you act on it.

Name an address in a page

In Markdown, :contact-line writes the whole sentence: "Write to hello@example.com." with a mailto: link. :contact-line{mailbox="legal"} names legal@ instead, as the sample terms and privacy pages do, and refunds uses the bare :contact-line. While the mailboxes have no domain, the line links the contact page ("Write to us from the contact page."), and it renders nothing while contact.enabled is false too. A mailbox other than hello or legal falls back the same way, and layers/kit/test/unit/content-components.test.ts(Licensees only) names the file and the value.

In code, read the address rather than writing it out: useMailbox('legal') in a page or component returns a computed, and siteMailbox(event, 'legal') in a route, job or task returns a string. Both are null while the mailboxes have no domain, and both take a typed name, so a misspelt mailbox fails typecheck. Neither reads NUXT_CONTACT_ADDRESS, so neither reveals a private contact address.

Change the page

layers/kit/app/pages/contact.vue(Licensees only) is a short page around two components. A page of yours at app/pages/contact.vue replaces it (Project structure) and can use them the same way:

  • <ContactForm @sent="..."> is the form. It fills in a signed-in account's name and address, and emits sent with the reply address once the message is accepted.
  • <ContactReveal> is the reveal. standalone draws it as a full-width button, for a page with no form.

Render each one only when its channel is in starter.contact.channels, since the route behind a channel that is off answers 404. The copy is under contact.* in each language's catalogue, and a key in your i18n/locales/<file> replaces the kit's. To link to the page from your own code, use <SupportLink> or useContactPath(), both of which follow contact.enabled.

Your page stays when contact.enabled is false, at app/pages/contact.vue or app/pages/contact/index.vue. Link to it yourself then: <SupportLink> renders nothing and useContactPath() is null while the switch is off.

A link with a lock opens the kit’s private repository, which every licensee can read.