"use client"; import { useState } from "react"; import { signIn, client } from "@/lib/auth-client"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, CardFooter, } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { toast } from "sonner"; import { Loader2 } from "lucide-react"; export default function ClientTest() { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [loading, setLoading] = useState(false); // Get the session data using the useSession hook const { data: session, isPending, error } = client.useSession(); const handleLogin = async () => { setLoading(true); await signIn.email( { email, password, callbackURL: "/client-test", }, { onResponse: () => { setLoading(false); }, onError: (ctx) => { toast.error(ctx.error.message); }, onSuccess: () => { toast.success("Successfully logged in!"); setEmail(""); setPassword(""); }, }, ); }; return (

Client Authentication Test

{/* Login Form */} Sign In Enter your email and password to sign in
setEmail(e.target.value)} />
setPassword(e.target.value)} />
{/* Session Display */} Session Information {isPending ? "Loading session..." : session ? "You are currently logged in" : "You are not logged in"} {isPending ? (
) : error ? (
Error: {error.message}
) : session ? (
{session.user.image ? ( Profile ) : (
{session.user.name?.charAt(0) || session.user.email?.charAt(0)}
)}

{session.user.name}

{session.user.email}

Session Details:

										{JSON.stringify(session, null, 2)}
									
) : (

Sign in to view your session information

)}
{session && ( )}
); }