Components
Wait List

Wait List

Join our cutting-edge Waitlist component! This uses Shadcn for UI, Framer Motion for animations, and Supabase for the database. Sign up for early access and updates!

Prerequisites

Before you start, ensure you have the following:

Install the Required Dependencies in your project:

  • shadcn ui
  • radix ui
  • framer motion
npm shadcn-ui@latest add button && npm shadcn-ui@latest add input && npm shadcn-ui@latest add toast && npm install @supabase/supabase-js

Create a new Project in superbse for reference check superbase check the video

Get Your API keys API URL, anon from supabase.

NEXT_PUBLIC_SUPABASE_URL=REPLACE_WITH_YOUR_KEY
NEXT_PUBLIC_SUPABASE_ANON_KEY=REPLACE_WITH_YOUR_KEY
You're almost done just few Steps left.

Installation

Create a file named waitlist.tsx and copy and paste the following code:

"use client";
 
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { useRouter } from 'next/navigation';
import React, { useState } from 'react';
import { createClient } from '@supabase/supabase-js';
import { useToast } from "@/components/ui/use-toast";
import clsx, { ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
 
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL!;
const supabaseKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!;
 
export const supabase = createClient(supabaseUrl, supabaseKey);
 
interface WaitlistProps {
  emailPlaceholder?: string;
  buttonText?: string;
  successRedirectUrl?: string;
  inputClassName?: string;
  buttonClassName?: string;
  formClassName?: string;
  onSuccess?: () => void;
  onError?: (error: any) => void;
}
 
export function cn(...inputs: ClassValue[]) {
  return twMerge(clsx(inputs));
}
 
export function Waitlist({
  emailPlaceholder = "Email",
  buttonText = "Subscribe",
  successRedirectUrl = "https://www.cedzlabs.com",
  inputClassName = "",
  buttonClassName = "",
  formClassName = "",
  onSuccess,
  onError,
}: WaitlistProps) {
  const [email, setEmail] = useState('');
  const router = useRouter();
  const { toast } = useToast();
 
  const handleSubscribe = async (e: React.FormEvent) => {
    e.preventDefault();
 
    const { error } = await supabase
      .from('waitlist')
      .insert([{ email }]);
 
    if (error) {
      console.error('Error subscribing:', error);
      toast({
        description: "Error subscribing: " + error.message,
      });
      if (onError) onError(error);
    } else {
      toast({
        description: "Successfully subscribed! You're added to the waitlist.",
      });
      setEmail('');
      if (onSuccess) onSuccess();
      router.push(successRedirectUrl); // Redirect after successful subscription
    }
  };
 
  return (
    <form onSubmit={handleSubscribe} className={cn("flex gap-2", formClassName)}>
      <Input
        type="email"
        value={email}
        onChange={(e) => setEmail(e.target.value)}
        placeholder={emailPlaceholder}
        className={cn("rounded-lg border border-neutral-800 focus:ring-2 focus:ring-teal-500 relative z-10 mt-4 bg-neutral-950 placeholder:text-neutral-700", inputClassName)}
      />
      <Button
        type="submit"
        className={cn("rounded-lg border border-neutral-800 focus:ring-2 focus:ring-teal-500 relative z-10 mt-4 placeholder:text-neutral-700", buttonClassName)}
      >
        {buttonText}
      </Button>
    </form>
  );
}
 
export Waitlist;

Create the following .env variables:

  NEXT_PUBLIC_SUPABASE_URL=REPLACE_WITH_YOUR_KEY
  NEXT_PUBLIC_SUPABASE_ANON_KEY=REPLACE_WITH_YOUR_KEY

Run the code in the SQLeditor in supabase.

  ALTER TABLE waitlist ENABLE ROW LEVEL SECURITY;

  -- Drop existing policy if it exists to avoid conflicts
  DROP POLICY IF EXISTS "Allow all users to insert" ON waitlist;

  -- Create a new policy to allow inserts
  CREATE POLICY "Allow all users to insert"
  ON waitlist
  FOR INSERT
  WITH CHECK (true);
Congrats! You have successfully created a Waitlist component for your project! 🎉

Examples

comming soon ...

Join Our Waitlist

Be the first to know when we launch. Subscribe to our newsletter!

Props

Prop nameTypeDefaultDescription
emailPlaceholderstring"Email"Customize the placeholder text for the email input
buttonTextstring"Subscribe"Customize the text of the subscribe button
successRedirectUrlstring"https://www.cedzlabs.com"URL to redirect to after a successful subscription
inputClassNamestring""Additional classes for the input element
buttonClassNamestring""Additional classes for the button element
formClassNamestring""Additional classes for the form element
onSuccessfunction-Callback function to be called after a successful subscription

Credits

NameCredit ForLink
YakkshitComponent Developeryakkshit
Cedz LabsVideo TutorialCedz Labs
snadcn uiUI componentssnadcn ui
supabaseDB, Documentationsupabase

Suggestions Or Book

NameCredit ForLink
YakkshitComponent Developer