eduproj2/components/LogoutButton.tsx
2023-08-01 18:53:51 -04:00

22 lines
537 B
TypeScript

"use client";
import { createClientComponentClient } from "@supabase/auth-helpers-nextjs";
import { useRouter } from "next/navigation";
export default function LogoutButton() {
const router = useRouter();
// Create a Supabase client configured to use cookies
const supabase = createClientComponentClient();
const signOut = async () => {
await supabase.auth.signOut();
router.refresh();
};
return (
<button className="bp5-button bp5-minimal bp5-icon-user" onClick={signOut}>
Logout
</button>
);
}