Skip to main content

useMagicLinkVerification

The useMagicLinkVerification hook validates magic-link token and attempt parameters against the auth API.

Return Value

loading
boolean
Whether client initialization or verification is in progress.
success
boolean | null
Verification result: true, false, or null before attempt.

Example

import { useEffect } from "react";
import { useMagicLinkVerification } from "@wacht/react-router";

function MagicLinkPage({ token, attempt }: { token: string; attempt: string }) {
  const { verifyMagicLink, success, loading } = useMagicLinkVerification();

  useEffect(() => {
    void verifyMagicLink({ token, attempt });
  }, [token, attempt, verifyMagicLink]);

  if (loading) return <div>Verifying...</div>;
  return <div>{success ? "Verified" : "Invalid link"}</div>;
}