← Building This Site

Part 2

Adding a newsletter to a static site

A static site has no database to store subscribers and no backend to call an email provider. Here's the small, serverless shape that works — plus the API-key gotcha that silently routes signups to the wrong place.

A newsletter form is three words of UI and a surprising amount of plumbing behind it. On a static, edge-hosted site there's no database to drop the email into and no always-on server to call your mail provider. This chapter is the minimal shape that works anyway, the build-vs-buy call most people get wrong, and the one gotcha — an API key that's almost powerful enough — that silently sends your subscribers nowhere.

The shape: form → action → provider's list

You don't store subscribers yourself. The subscriber list lives in your email provider (Resend, Beehiiv, ConvertKit, Mailchimp…), and your job is just to hand new emails to it. On an edge/static site, the glue is a single server action (or a tiny API route) that runs on demand.

Signup form
(client)

Server action
(runs on demand)

Email provider API
add contact to a list

The list lives
in the provider

(optional)
send welcome email

Three properties make this fit a static site:

  • No database. The provider is the database. Your repo never stores a subscriber, which is also the right call for privacy — emails live in one place you can export, not scattered in your app DB.
  • No always-on backend. The action is serverless: it spins up for the one request and dies. A form post is the only dynamic thing on an otherwise fully-prerendered site.
  • The secret stays server-side. The provider API key is a server secret (set as a Worker/platform secret, never shipped to the browser). The client form just calls your action; the action holds the key.

Build vs. buy: check the framework first

Before you build the signup flow, check what your framework already gives you — and be ready for the answer to be "less than you think." Many SaaS starters ship transactional email (password resets, receipts) via a sendMail helper, but not newsletter/audience management. Those are different products: transactional email sends one message to one person; a newsletter manages a list and broadcasts to it.

Audiences / lists (usually NOT built in)

add contact to list

broadcast to many

Transactional (often built in)

sendMail(to, template)

one message,
one recipient

So the realistic split is: use the framework's mail setup if it has one, but expect to wire the audience part yourself against the provider's API. That's not a failure of the framework — list management is a genuinely separate concern. The lesson that generalizes: read what the tool actually covers before you assume the feature exists.

The gotcha: a key that's almost enough

Here's the one that costs an afternoon. Email providers scope API keys by permission, and the two things you're doing — sending a message and managing a contact list — are different permissions. A key created for "sending" often cannot add a contact to an audience.

The failure is quiet. The send succeeds, the form shows success, and you assume the list is filling up — but contacts were never added, because that key was never allowed to.

Send only

Send only

Full / audience

What can your
API key do?

Can send email

CANNOT add to a list
(silently fails)

Can send AND
manage the list

Two defenses, both worth building in:

  • Make the action degrade loudly, not silently. If the add-to-list call returns a permission error, don't pretend it worked. Log it, and ideally fall back to something that does work with a send-only key — e.g. email yourself a notification for each signup — so no subscriber is lost while you fix the key.
  • Verify the round trip, not the form. A green success message only proves the request didn't throw. Confirm a test signup actually appears in the provider's audience (check the dashboard or query the list API). "The form said success" is not "the contact is on the list."

The welcome email (and why it waits)

A welcome email is a nice touch — it confirms the subscription and sets expectations. But it has a prerequisite most newsletter tutorials skip: to send from your own domain (hello@yourdomain.com), you must verify a sending domain with the provider first. Until you do, you can usually only send from the provider's shared test address, which most providers will only deliver to your own account email.

So the sensible order is: get add-to-list working first (that's the core), then verify your sending domain, then turn on the welcome email from your brand address. Domain verification — SPF, DKIM, DMARC, and the DNS records that make email trust you — is its own rabbit hole, and it's the next chapter.

The scoreboard

StorageNone of your own — the list lives in the email provider
The glueOne server action: form → provider API (key stays server-side)
Framework gives youUsually transactional sendMail; not audience/list management
The trapA send-only key can't add contacts — fails silently
DefensesDegrade loudly + a fallback path; verify the contact lands, not just the form
Welcome emailNeeds a verified sending domain first — do it after add-to-list works

A newsletter on a static site isn't a backend you have to run; it's one small function that hands an email to someone else's list. Get the key's permissions right, verify the contact actually lands, and the rest is copywriting.