Skip to content
Early bird + Black Friday · 73% off

Get ZeroDirs for $179 $49

Claim $49 deal

Newsletter

The newsletter block sits in every content page footer. features.newsletter sets the mode: 'off', 'embed' or 'd1'.

  1. Paste the provider’s form.

    site.config.ts
    features: { newsletter: 'embed' },
    newsletter: {
    heading: 'New tools, weekly',
    blurb: 'One email a week. No spam.',
    embedHtml: '<form action="https://provider.example/subscribe" method="post"><input type="email" name="email" /><button>Subscribe</button></form>',
    },

    pnpm check:config answers site.config.ts OK — <name> (<url>).

  2. Build, and read the zero-JS line.

    Terminal
    pnpm build
  3. Deploy: pnpm deploy or a push.

What Where Expect
Block any content footer heading, blurb, d1 form or embed
Row pnpm exec wrangler d1 execute DB --remote --command "SELECT count(*) AS n FROM subscribers WHERE unsubscribed_at IS NULL" n counts your address
Count /admin/stats/ Newsletter subscribers — n/a unless d1
Zero JS build log zero-js: <n> content pages, 0 islands, 0 external scripts — ok
  • embed renders newsletter.embedHtml unsanitised; a <script src> fails the build: content pages must ship zero JavaScript.

  • The form posts to /api/newsletter/ — the trailing slash matters, /api/newsletter earns a 308. The 303 reply carries #newsletter-thanks, #newsletter-invalid or #newsletter-unavailable.

  • features.honeypot adds a hidden company field.

  • No unsubscribe flow; the starter sends no newsletter. An address unsubscribed by hand stays unsubscribed: ON CONFLICT DO NOTHING skips existing rows.

    Terminal
    pnpm exec wrangler d1 execute DB --remote --command "UPDATE subscribers SET unsubscribed_at = unixepoch() WHERE email = 'gone@example.com'"
  • Export the list (created_at is unix seconds):

    Terminal
    pnpm exec wrangler d1 execute DB --remote --json --command "SELECT email, created_at FROM subscribers WHERE unsubscribed_at IS NULL ORDER BY created_at" > subscribers.json
State Visitor sees /admin/ reports Fix
'off' (default) no block; /api/newsletter/ answers 404 stats: n/a —
'embed', no embedHtml heading and blurb, no form n/a set embedHtml
'embed' with <script src> build fails — use a plain form
Honeypot filled “Thanks — you are on the list.”; nothing stored — —
Bad address “That does not look like an email address.” — —
D1 refuses the write “Sign-up is temporarily unavailable.” newsletter: signup failed in the Worker log wait, or Workers Paid

features.newsletter, features.honeypot, newsletter.heading, newsletter.blurb and newsletter.embedHtml — features, newsletter.

  • src/components/site/Newsletter.astro — the block, the three fragments, the honeypot
  • src/components/site/Footer.astro — where it mounts
  • src/pages/api/newsletter.ts — handleSignup(), the 303
  • src/db/schema.ts — subscribers
  • src/templates/admin/StatsPage.astro — the subscriber count
  • src/config/defaults.ts — DEFAULT_NEWSLETTER
  • integrations/budget.ts — the zero-JS check