The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
import { Button } from "@dub/ui";
import { Google } from "@dub/ui/icons";
import { signIn } from "next-auth/react";
import { useSearchParams } from "next/navigation";
import { useContext } from "react";
import { LoginFormContext } from "./login-form";
export function GoogleButton({ next }: { next?: string }) {
const searchParams = useSearchParams();
const finalNext = next ?? searchParams?.get("next");
const { setClickedMethod, clickedMethod, setLastUsedAuthMethod } =
useContext(LoginFormContext);
return (
<Button
text="Continue with Google"
variant="secondary"
onClick={() => {
setClickedMethod("google");
setLastUsedAuthMethod("google");
signIn("google", {
...(finalNext && finalNext.length > 0
? { callbackUrl: finalNext }
: {}),
});
}}
loading={clickedMethod === "google"}
disabled={clickedMethod && clickedMethod !== "google"}
icon={<Google className="size-4" />}
/>
);
}