skalara-web/components/logout.tsx
2023-07-26 18:30:00 -04:00

20 lines
515 B
TypeScript

"use client";
import { createClientComponentClient } from "@supabase/auth-helpers-nextjs";
import { useRouter } from "next/navigation";
import { Button } from "@/components/ui/button";
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 onClick={signOut}>Logout</Button>;
}