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