Building a Viral Waitlist With Next.js, Prisma, and Resend (With Referral Tracking)
A waitlist is often the first real infrastructure a SaaS needs. Done right, it validates demand, builds an email list, and creates social proof. Here's the full stack implementation. What We're Bui...

Source: DEV Community
A waitlist is often the first real infrastructure a SaaS needs. Done right, it validates demand, builds an email list, and creates social proof. Here's the full stack implementation. What We're Building Waitlist signup form with email + optional name Confirmation email sent immediately (Resend) Position tracking (show users their spot) Referral tracking for viral growth Admin endpoint to batch-invite users Database Schema model WaitlistEntry { id String @id @default(cuid()) email String @unique name String? position Int @unique @default(autoincrement()) referralCode String @unique @default(cuid()) referredBy String? // referralCode of the person who referred them referralCount Int @default(0) status String @default("waiting") // waiting | invited | active invitedAt DateTime? createdAt DateTime @default(now()) @@index([status]) @@index([referralCode]) } Signup API Route // app/api/waitlist/route.ts import { NextRequest } from 'next/server' import { z } from 'zod' import { db } from '@/l