Anticode Open builder

Resend email for the Next.js export: confirmations, sign-in links and alerts

The Next.js app you export from Anticode sends its email through Resend's HTTP API. Set RESEND_API_KEY and it sends booking confirmations, sign-in links, team invites and owner alerts. Leave it empty while developing and those emails are printed to the terminal instead, so magic links still work on your laptop.

Updated · By the Anticode team

The emails the app sends

Every email in the exported app
EmailSent toWhen
Booking confirmedThe customerAfter a booking is saved, with the service, day and time
Your sign-in linkA customerWhen they ask to sign in; the link works once and expires in 15 minutes
You're invitedA new team memberWhen an owner adds an admin or staff member; the link expires in 48 hours
New booking / New messageNOTIFY_EMAILAfter each booking or contact message, if NOTIFY_EMAIL is set

Every email has a plain-text part and a simple HTML part. Customer and visitor text is HTML-escaped before it goes into the HTML, so a name like <b>Ana</b> arrives as typed. Newsletter sign-ups don't trigger an email; the app stores the address and leaves sending newsletters to you.

The three variables

RESEND_API_KEY
Your Resend API key. With it set, the app posts each email to Resend.
EMAIL_FROM
The sender, as Name <address>. The example file holds a placeholder at example.com, which you must replace with an address on a domain you've verified in Resend.
NOTIFY_EMAIL
Where owner alerts go. Leave it empty and no alerts are sent.

APP_URL matters too: sign-in and invite links are built from it, so in production it must be the site's public https address, not localhost.

Set up Resend

  1. Create a Resend account and add your domain. Resend's domains overview says you must verify at least one domain to send, and recommends sending from a subdomain such as mail.yourdomain.com to keep its reputation separate.
  2. Add the DNS records Resend generates. Its add-a-domain guide says they cover SPF and DKIM as TXT and MX or CNAME records, must match exactly, and that a CNAME shouldn't be proxied, for example through Cloudflare's orange cloud.
  3. Once the domain shows as verified, create an API key and put it in RESEND_API_KEY on your host.
  4. Set EMAIL_FROM, for example Harbour Yoga <bookings@mail.harbouryoga.com>, and NOTIFY_EMAIL.
  5. Make a test booking with your own address and check both the confirmation and the owner alert.

Development without a key

When RESEND_API_KEY is empty and the app isn't running in production, lib/mail.ts prints each email to the server log instead of sending it: the recipient, the subject, the lines and any link. That's how you sign in as a customer or accept a team invite on localhost: copy the link from the terminal. Nothing leaves your machine. Resend email for nextjs export projects only becomes necessary when real people need to receive messages.

Production without a key

In production the app refuses to pretend. With no key, sending throws an error instead of logging. What that means for each email:

  • Bookings are still saved and the customer sees the confirmed message on the page; only the confirmation email fails, and the error is logged.
  • Owner alerts fail quietly into the log; the visitor never sees an error.
  • Sign-in links and invites can't be delivered, so customers and new staff can't get in. Set the key before you rely on accounts.

Replies and deliverability

The booking confirmation says "Need to change it? Reply to this email." Replies go to the EMAIL_FROM address, so make it a mailbox someone reads, or set up receiving for it. Each send has an eight-second timeout. If messages land in spam, the usual causes are an unverified domain, a sender domain that doesn't match the verified one, or missing DMARC; our guide to SPF, DKIM and DMARC covers the records.

Limits

  • Only Resend is wired in. Swapping to another provider means editing sendMail in lib/mail.ts.
  • There's no queue or retry: an email that fails is logged, not resent.
  • No newsletter sending, templates or open tracking.
  • This applies to the exported app only. Sites hosted on Anticode send owner alerts through Anticode's own email.

More on the exported project: Next.js export, deploying a Next.js app and Postgres.

Questions people ask

Do I need Resend to try the app?

No. In development, emails and sign-in links are printed to the terminal.

Can I send from a Gmail address?

Resend sends from domains you verify, so use an address on your own domain.

Who gets the new-booking alert?

Whoever is in NOTIFY_EMAIL. Leave it empty to switch alerts off.

Sources

  1. Resend Docs: Domains, checked
  2. Resend Docs: Add a domain, checked