eduproj2/components/LogoutButton.tsx
Michael Zhang 1711557f4c initial
2023-08-01 18:38:06 -04:00

25 lines
590 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="py-2 px-4 rounded-md no-underline bg-btn-background hover:bg-btn-background-hover"
onClick={signOut}
>
Logout
</button>
)
}