WaitKitWaitKit
JavaScript SDK

React Hook

Use the useWaitlist hook to integrate waitlist functionality into React components.

The useWaitlist hook provides reactive state for joining a waitlist and fetching subscriber counts.

Setup

The hook is imported from waitkit/react and requires a configured WaitKit instance.

import { WaitKit } from "waitkit";
import { useWaitlist } from "waitkit/react";

const wk = new WaitKit({
  apiKey: "wk_...",
  projectSlug: "my-project",
});

Usage

function WaitlistForm() {
  const { join, count, isJoining, isLoading, error, refetchCount } =
    useWaitlist(wk);

  const handleSubmit = async (e: React.FormEvent) => {
    e.preventDefault();
    await join({ email: "user@example.com" });
  };

  return (
    <form onSubmit={handleSubmit}>
      <p>Subscribers: {count}</p>
      <button disabled={isJoining || isLoading} type="submit">
        {isJoining ? "Joining..." : "Join Waitlist"}
      </button>
      {error && <p>{error.message}</p>}
    </form>
  );
}

Return values

ValueTypeDescription
join(opts: JoinOptions) => Promise<JoinResult>Submits a waitlist signup
countnumber | undefinedCurrent subscriber count
isJoiningbooleanTrue while a join request is in flight
isLoadingbooleanTrue during the initial count fetch
errorError | nullLast error from join or count
refetchCount() => voidManually refetch the subscriber count

The hook fetches the subscriber count on mount and refetches it automatically after a successful join.

On this page