"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 (
{session.user.name}
{session.user.email}
Session Details:
{JSON.stringify(session, null, 2)}
Sign in to view your session information