Launch Waitlist KitLaunch Waitlist KitPre-launch waitlist app with referral queue boosts, admin CMS, email capture, CSV export, webhooks, and an embeddable signup form—built on Next.js 16 and Prisma.$24

A single-step waitlist signup is fast to ship but it also accepts throwaway addresses, typo domains, and bot traffic that never opens your launch email.Waitlist double opt-in with a confirmation email in Next.jscloses that gap: the user proves they control the inbox before you count them toward queue position or referral boosts.

This guide implements the fullResend + Next.js waitlist double opt-inpattern on the App Router: store aconfirmationTokenin Prisma, send a confirm link after signup, setconfirmedAton click, and only then show the status page and count referrals forreferral queue position. Optional double opt-in is a common requirement for GDPR-friendly consent and for anti-gaming referral loops.


What double opt-in changes in your waitlist

Without opt-in With double opt-in Signup → immediate status page Signup → “Check your email” → confirm → status page Referrals count on insert Referrals count only afterconfirmedsignup Higher list noise Cleaner list; fewer fake referral credits

The referral waitlist from article 01 already filters boosts withconfirmedAt: { not: null }. This post wires the email step that makes that filter meaningful.

Prerequisites

  • Next.js 14+ App Router (Next.js 16 uses the same Route Handler patterns).

  • Prisma + PostgreSQL (or any Prisma-supported database).

  • Resendaccount and a verified sending domain.

  • Signup flow fromreferral waitlist + queue position(or equivalentWaitlistEntrymodel).


Step 1: Extend the Prisma waitlist model

Add fields for the confirmation lifecycle. KeepconfirmedAtnullable until the user clicks the link.

model WaitlistEntry {
  id                 String    @id @default(cuid())
  email              String    @unique
  referralCode       String    @unique
  referredById       String?
  basePosition       Int
  confirmationToken  String?   @unique
  confirmationSentAt DateTime?
  confirmedAt        DateTime?
  createdAt          DateTime  @default(now())

  referredBy    WaitlistEntry?  @relation("Referrals", fields: [referredById], references: [id])
  referrals     WaitlistEntry[] @relation("Referrals")
}

Design notes:

  • confirmationToken— opaque, single-use secret in the URL (not the publicreferralCode).

  • confirmationSentAt— optional audit field for support (“resend confirm” throttling).

  • confirmedAt— set once when opt-in succeeds; never clear it unless the user deletes their entry.

Generate tokens withcrypto.randomBytes(32).toString("hex")or equivalent. Runprisma migrate devafter editing the schema.

If double opt-in isoptionalin your product, gate behavior withprocess.env.WAITLIST_DOUBLE_OPT_IN === "true"so staging can stay single-step.


Step 2: Resend client and environment variables

Install the SDK:

npm install resend

Add to.env:

RESEND_API_KEY=re_...
RESEND_FROM_EMAIL=Waitlist <waitlist@yourdomain.com>
NEXT_PUBLIC_APP_URL=https://yourwaitlist.com
WAITLIST_DOUBLE_OPT_IN=true

Verify your domain in the Resend dashboard before production sends. Use a subdomain (waitlist@mail.yourdomain.com) if marketing uses a different ESP.

Createlib/email/resend.ts:

import { Resend } from "resend";

export const resend = new Resend(process.env.RESEND_API_KEY);

export function waitlistFromAddress(): string {
  const from = process.env.RESEND_FROM_EMAIL;
  if (!from) throw new Error("RESEND_FROM_EMAIL is not set");
  return from;
}

export function appBaseUrl(): string {
  const url = process.env.NEXT_PUBLIC_APP_URL;
  if (!url) throw new Error("NEXT_PUBLIC_APP_URL is not set");
  return url.replace(/\/$/, "");
}

For richer HTML later, seeReact Email + Resend waitlist templatesin this series. Plain text or minimal HTML is enough for v1.


Step 3: Send the confirmation email

lib/email/waitlist-confirm.ts:

import { resend, waitlistFromAddress, appBaseUrl } from "@/lib/email/resend";

export async function sendWaitlistConfirmationEmail(params: {
  to: string;
  token: string;
}) {
  const confirmUrl = `${appBaseUrl()}/api/waitlist/confirm?token=${encodeURIComponent(params.token)}`;

  await resend.emails.send({
    from: waitlistFromAddress(),
    to: params.to,
    subject: "Confirm your spot on the waitlist",
    text: [
      "Thanks for signing up.",
      "",
      "Confirm your email to secure your place and unlock your referral link:",
      confirmUrl,
      "",
      "If you did not request this, ignore this message.",
    ].join("\n"),
    html: `<p>Thanks for signing up.</p>
<p><a href="${confirmUrl}">Confirm your email</a> to secure your place and unlock your referral link.</p>
<p>If you did not request this, ignore this message.</p>`,
  });
}

Why a Route Handler for confirm?One GET click from the inbox works without JavaScript. You can redirect to/status?code=...after settingconfirmedAt.


Step 4: Update signup to create token and send mail

ModifyPOST /api/waitlist/signupwhenWAITLIST_DOUBLE_OPT_INis enabled:

import { randomBytes } from "crypto";
import { NextResponse } from "next/server";
import { db } from "@/lib/db";
import { generateReferralCode, nextBasePosition } from "@/lib/waitlist";
import { sendWaitlistConfirmationEmail } from "@/lib/email/waitlist-confirm";

const doubleOptIn = process.env.WAITLIST_DOUBLE_OPT_IN === "true";

export async function POST(request: Request) {
  const body = await request.json();
  const email = typeof body.email === "string" ? body.email.trim().toLowerCase() : "";
  const ref = typeof body.ref === "string" ? body.ref.trim() : null;
  const consent = body.consent === true;

  if (!email || !consent) {
    return NextResponse.json({ error: "Invalid input" }, { status: 400 });
  }

  const existing = await db.waitlistEntry.findUnique({ where: { email } });
  if (existing) {
    if (doubleOptIn && !existing.confirmedAt && existing.confirmationToken) {
      await sendWaitlistConfirmationEmail({
        to: existing.email,
        token: existing.confirmationToken,
      });
      return NextResponse.json({
        pendingConfirmation: true,
        referralCode: existing.referralCode,
        existing: true,
      });
    }
    return NextResponse.json({
      referralCode: existing.referralCode,
      confirmed: !!existing.confirmedAt,
      existing: true,
    });
  }

  let referredById: string | undefined;
  if (ref) {
    const referrer = await db.waitlistEntry.findUnique({
      where: { referralCode: ref },
    });
    if (referrer) referredById = referrer.id;
  }

  const referralCode = generateReferralCode();
  const basePosition = await nextBasePosition();
  const confirmationToken = doubleOptIn ? randomBytes(32).toString("hex") : null;

  const entry = await db.waitlistEntry.create({
    data: {
      email,
      referralCode,
      referredById,
      basePosition,
      confirmationToken,
      confirmedAt: doubleOptIn ? null : new Date(),
      confirmationSentAt: doubleOptIn ? new Date() : null,
    },
  });

  if (doubleOptIn && confirmationToken) {
    await sendWaitlistConfirmationEmail({ to: email, token: confirmationToken });
    return NextResponse.json({
      pendingConfirmation: true,
      referralCode: entry.referralCode,
      existing: false,
    });
  }

  return NextResponse.json({
    referralCode: entry.referralCode,
    pendingConfirmation: false,
    existing: false,
  });
}

Duplicate email UX:If someone signs up again unconfirmed, resend the same token (or rotate token in a transaction if you prefer stricter security). Never create a second row—emailis unique.

Referral attribution:referredByIdis set at signup time, before confirm. The referrer’s queue boost still waits untilconfirmedAtis set on the new row—matchingcountVerifiedReferralsin the queue post.


Step 5: Confirm Route Handler

Createapp/api/waitlist/confirm/route.ts:

import { NextResponse } from "next/server";
import { db } from "@/lib/db";
import { appBaseUrl } from "@/lib/email/resend";

export async function GET(request: Request) {
  const { searchParams } = new URL(request.url);
  const token = searchParams.get("token");

  if (!token) {
    return NextResponse.redirect(`${appBaseUrl()}/confirm?error=missing_token`);
  }

  const entry = await db.waitlistEntry.findUnique({
    where: { confirmationToken: token },
  });

  if (!entry) {
    return NextResponse.redirect(`${appBaseUrl()}/confirm?error=invalid_token`);
  }

  if (entry.confirmedAt) {
    return NextResponse.redirect(
      `${appBaseUrl()}/status?code=${encodeURIComponent(entry.referralCode)}`,
    );
  }

  await db.waitlistEntry.update({
    where: { id: entry.id },
    data: {
      confirmedAt: new Date(),
      confirmationToken: null,
    },
  });

  // Optional: POST to WAITLIST_WEBHOOK_URL — see waitlist webhook post in this series
  // await notifyWaitlistWebhook({ event: "waitlist.confirmed", entryId: entry.id });

  return NextResponse.redirect(
    `${appBaseUrl()}/status?code=${encodeURIComponent(entry.referralCode)}&confirmed=1`,
  );
}

ClearingconfirmationTokenafter success prevents link replay from doing extra work. Idempotent confirm (already confirmed) still sends users to their status page.


Step 6: Pending and error pages in the App Router

After signup, the client should branch onpendingConfirmation:

"use client";

export function WaitlistForm({ defaultRef }: { defaultRef: string }) {
  async function onSubmit(e: React.FormEvent<HTMLFormElement>) {
    e.preventDefault();
    const form = new FormData(e.currentTarget);
    const res = await fetch("/api/waitlist/signup", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({
        email: form.get("email"),
        consent: form.get("consent") === "on",
        ref: form.get("ref") || undefined,
      }),
    });
    const data = await res.json();
    if (data.pendingConfirmation) {
      window.location.href = "/confirm/pending";
      return;
    }
    if (data.referralCode) {
      window.location.href = `/status?code=${encodeURIComponent(data.referralCode)}`;
    }
  }

  return (
    <form onSubmit={onSubmit}>
      <input type="hidden" name="ref" defaultValue={defaultRef} />
      <input type="email" name="email" required />
      <label>
        <input type="checkbox" name="consent" required /> I agree to receive updates.
      </label>
      <button type="submit">Join waitlist</button>
    </form>
  );
}

app/confirm/pending/page.tsx— static copy: “Check your inbox and click the confirmation link.”

app/confirm/page.tsx— readsearchParams.errorfor friendly messages when tokens are missing or invalid.


Step 7: Gate the status page until confirmed

Onapp/status/page.tsx, if the entry exists butconfirmedAtis null, show pending instructions instead of position and share link:

const entry = await db.waitlistEntry.findUnique({
  where: { referralCode: code },
});

if (!entry) return <p>We could not find that waitlist entry.</p>;

if (!entry.confirmedAt) {
  return (
    <main>
      <h1>Almost there</h1>
      <p>Confirm your email to see your queue position and referral link.</p>
      <p>We sent a link to {entry.email.replace(/(.{2}).+(@.+)/, "$1…$2")}.</p>
    </main>
  );
}

// ... getEffectivePosition, share URL, etc.

That stops users from sharing a referral code before they confirm referrals still attach on signup, but public status stays locked until opt-in completes.

Admin visibility:In a later admin post, filter signups byconfirmedAt IS NULLso support can see pending vs verified counts without querying Resend logs.


Step 8: Production checklist

  1. Resend domain— SPF/DKIM green in dashboard; test with your own inbox.

  2. NEXT_PUBLIC_APP_URL— production canonical URL (notlocalhost) so confirm links work behind Vercel.

  3. Rate limits— throttle signup and confirm resends per IP; pair withhoneypot and rate limitingon the signup route.

  4. Monitoring— log Resend API errors; alert on spike ininvalid_tokenredirects.

  5. Feature flag— keepWAITLIST_DOUBLE_OPT_INdocumented in your env checklist (week 11 in this series).


Common failures

Referrer’s position never improves

The referred user signed up but never clicked confirm. Fix: ensurecountVerifiedReferralsfiltersconfirmedAt: { not: null }(article 01). Do not count rows on insert alone.

Confirm link goes to localhost

NEXT_PUBLIC_APP_URLmissing or wrong in Vercel production env. Set it explicitly per environment.

User confirms but sees “invalid token”

Token was rotated on resend while they clicked an old email. Prefer resending the same token or invalidate old links clearly in copy.

Double opt-in off but schema expects tokens

WhenWAITLIST_DOUBLE_OPT_INis false, setconfirmedAt: new Date()on create so status and referrals behave like single-step.

Emails land in spam

Use a verified domain, minimal links, and consistentfromaddress. Avoid URL shorteners in confirm links.

Should you resend confirmation on every duplicate signup?

Throttle resends (for example one email per 60 seconds per address) to prevent harassment if someone spams the form with a victim’s email. LogconfirmationSentAtand return429when throttled.


Optional double opt-in without rebuilding the stack

Confirmation tokens, Resend integration, pending UX, verified referral counts, and admin visibility are the same pieces every pre-launch team reimplements.

Launch Waitlist KitfromSkryptixincludes:

  • Referral waitlist with queue boosts and status pages

  • Optionaldouble opt-inand confirmation emails

  • Honeypot, consent, rate limiting, webhooks, and/embed

  • Admin signups, CSV export, and landing CMS

Optional double opt-in and confirmation emails are included in Launch Waitlist Kit.

Get Launch Waitlist Kit →

Launch Waitlist KitLaunch Waitlist KitPre-launch waitlist app with referral queue boosts, admin CMS, email capture, CSV export, webhooks, and an embeddable signup form—built on Next.js 16 and Prisma.$24

FAQ

What is waitlist double opt-in in Next.js?

The user submits email on your landing page, receives a confirmation link via email (for example through Resend), and only becomes an active waitlist member after clicking that link. You store pending state in Prisma with a token and setconfirmedAtwhen they confirm.

Why use double opt-in for a referral waitlist?

It reduces fake signups and ensures referral boosts apply only when invited friends verify real inboxes. That aligns queue math with trustworthy growth instead of inflated referral counts.

How do I send waitlist confirmation emails with Resend?

Create a Resend client withRESEND_API_KEY, build a confirm URL pointing to your Route Handler, and callresend.emails.sendafter signup when double opt-in is enabled. Use a verifiedfromdomain in production.

Should I use GET or POST for the confirm link?

GET on/api/waitlist/confirm?token=...is standard so email clients can open the link without a form. Validate the token server-side, update Prisma once, then redirect to the status page.

Can existing signups stay single-step while new users use double opt-in?

Use an env flag and setconfirmedAtimmediately when opt-in is disabled. Existing rows with nullconfirmedAtcan be backfilled in a one-off migration if you turn opt-in on later.


Written by the team behind Skryptix. We build Launch Waitlist Kit so founders can focus on the launch—not waitlist infrastructure.