Setting up your project
For the Business website template on Next.js 16 with Resend. Only what your project uses, in the order to do it.
Build this guide for your project
1. Run the project
- 1Unzip the download and open a terminal in the folder. Run
npm install. - 2Copy
.env.exampleto.env.localand fill in the 3 required values:RESEND_API_KEY,EMAIL_FROM,CONTACT_TO_EMAIL. Each provider section below says where to get them. - 3Run
npm run devand openhttp://localhost:3000. This is a Next.js 16 project (Turbopack by default); it needs Node 20 or newer. - 4The
README.mdinside the project repeats this guide under Go live, so you can hand the folder to someone else.
Pages in the Business website template
//products/pricing/about/support/contact/terms/privacy
2. Resend (email)
Your project's contact form and newsletter signup send real email through Resend. You need an API key and two addresses. Until they are set, the forms show a friendly "not configured" message instead of failing.
Values you will paste into .env.local
RESEND_API_KEYAPI key from the Resend dashboard → API Keys → Create. Permission: Sending access; you can also restrict it to your sending domain. That is all the site needs.Secret.EMAIL_FROMThe address emails are sent from. Must be on a domain you verified in Resend, e.g. hello@yourdomain.com. While testing you can use onboarding@resend.dev.CONTACT_TO_EMAILWhere contact form messages are delivered. Any inbox you read.RESEND_AUDIENCE_IDResend audience to add newsletter subscribers to (Audiences → your audience → the id in the URL). Only used when Supabase is off; with Supabase on, subscribers are stored in your database.FORMS_SECRETUsed when Supabase is on. A password only your server knows: the database functions that store subscribers and contact messages refuse any call without it, so the public Supabase key alone can never write to your lists. Running supabase/migrations/0002_forms.sql prints the value; paste it here.Secret.
Get an API key
- 1Create an account at resend.com. The free tier covers a small site.
- 2Open API Keys in the left sidebar and click Create API Key. Name it after your site, give it Sending access, and copy the key. It is shown once.
Verify your domain
- 1Open Domains and click Add Domain. Enter the domain your site will live on, for example
yourdomain.com. - 2Resend shows DNS records to add (an MX, a TXT for SPF, and a TXT for DKIM). Add them at your DNS provider. If your DNS is on Cloudflare: DNS → Records → Add record, one per row, exactly as shown.
- 3Click Verify. It usually takes a few minutes, occasionally up to an hour.
- 4Until the domain verifies, you can test with
EMAIL_FROM=onboarding@resend.dev, which can only send to the email address of your Resend account.
Paste the values into the env file
- 1If you haven't yet, copy
.env.exampleto.env.local. - 2Fill in the Resend section:
RESEND_API_KEY=re_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx EMAIL_FROM=hello@yourdomain.com CONTACT_TO_EMAIL=you@yourdomain.com # With Supabase on: the value supabase/migrations/0002_forms.sql prints FORMS_SECRET= # Without Supabase: newsletter storage in a Resend audience RESEND_AUDIENCE_ID=
RESEND_API_KEY is a secret: keep it out of git and out of the browser. It is only read on the server.
Try it
- 1Restart
npm run dev, open/contact, and send yourself a message. It arrives atCONTACT_TO_EMAIL, and the sender gets an auto-reply. - 2Enter an email in the footer newsletter box. With Supabase on, click the confirmation link; otherwise the welcome email arrives straight away.
- 3Use Resend's Emails page to see every message and its delivery status.
Use Resend for Supabase's sign-up emails too
- 1Supabase's built-in mailer allows only a few emails per hour and is meant for testing.
- 2In Supabase open Authentication → SMTP Settings, enable Custom SMTP, and enter host
smtp.resend.com, port465, usernameresend, and your Resend API key as the password. Sender email is yourEMAIL_FROM.
What was added to your project
lib/email/resend.ts, lib/email/templates.tslib/forms/guard.ts (honeypot + rate limit)lib/safe-next.ts (keeps the redirect back to the form on this site)components/forms/form-status.tsxapp/contact/actions.ts, app/newsletter/actions.tsapp/newsletter/confirm/route.ts, app/newsletter/unsubscribe/page.tsx and supabase/migrations/0002_forms.sql (when Supabase is on)lib/forms/messages.ts (the copy behind every ?sent= and ?error= code)
If something goes wrong
- “Email is not configured yet”: One of the three required values is missing from
.env.local, or the dev server was started before you saved it. Restart it. - Resend returns 403 or “domain is not verified”:
EMAIL_FROMmust be on a verified domain. Check the DNS records in Resend → Domains, or useonboarding@resend.devwhile testing. - The message says sent but nothing arrives: Check Resend → Emails for the delivery status, then the spam folder of
CONTACT_TO_EMAIL. - “Too many messages from this connection”: The rate limit is 5 submissions per 10 minutes per IP. Wait, or raise
MAX_PER_WINDOWinlib/forms/guard.ts. - “Form storage is not configured yet”:
FORMS_SECRETis missing from.env.local, or still the placeholder. Runsupabase/migrations/0002_forms.sqlin the SQL editor and paste the 64-character value it prints; on a deployed site push it withnpm run cf:secrets. - “The site's public URL is not set”: With Supabase on, the newsletter confirmation link is built from
NEXT_PUBLIC_SITE_URL. On a deployed site it is missing or stillhttp://localhost:3000; set it to your domain in the host's environment (with Cloudflare: in.env.local, thennpm run cf:secrets).
Missing something? See the full reference. Back to the builder