Capture leads
Collect email addresses before your product is ready — build your waitlist first, sell later.
1. Create the leads table in Supabase
Open the Supabase SQL Editor and run:
create table public.leads (
id uuid default gen_random_uuid(),
email text unique,
created_at timestamp with time zone default timezone('utc'::text, now()) not null,
primary key (id)
);
alter table public.leads enable row level security;
create policy insert_lead on public.leads
for insert
to public
with check (true);2. Add your Supabase service role key
# .env.local
NEXT_PUBLIC_SUPABASE_URL=https://xxxx.supabase.co
SUPABASE_SERVICE_ROLE_KEY=eyJ...3. Add the LeadMagnet component to your page
Drop <LeadMagnet /> anywhere on your landing page — below the hero is a common spot:
import LeadMagnet from "@/components/LeadMagnet";
// In your page:
<LeadMagnet />The component handles the form state and calls /api/lead on submission. The route saves the email to your leads table and sends a delivery email via Resend.
4. Customize the form and email
- Edit the headline and button copy in
src/components/LeadMagnet.tsx. - Edit the email sent to subscribers in
src/emails/LeadMagnetEmail.tsx— change the subject, body copy, and any download link you want to include.
5. Set up Resend (for email delivery)
# .env.local
RESEND_API_KEY=re_xxxxxxxxxxxxxxxxSee the Email guide for full Resend setup steps. Without a key, the route still saves the email to the database — just no delivery email is sent.
TipEmail addresses collected before launch are gold. Message them personally when you go live — a personal note converts far better than a broadcast.