"use client"; import { useState } from "react"; import { authClient } from "../lib/auth-client"; export function SignOutButton() { const [pending, setPending] = useState(false); const [error, setError] = useState(null); async function signOut() { setPending(true); setError(null); try { const response = await authClient.signOut(); if (response.error) { setError(response.error.message ?? "Could not sign out."); setPending(false); return; } window.location.assign("/"); } catch { setError("Could not reach the authentication service."); setPending(false); } } return (
{error ? ( {error} ) : null}
); }