← back to Dear Bubbe Nextjs
components/SignOutButton.tsx
23 lines
'use client';
import { signOut } from 'next-auth/react';
export default function SignOutButton() {
const handleSignOut = async () => {
// Sign out and redirect to sign-in page
// This ensures clean logout and forces account selection on next login
await signOut({
callbackUrl: '/auth/signin',
redirect: true
});
};
return (
<button
onClick={handleSignOut}
className="text-sm text-gray-500 hover:text-gray-700 underline"
>
Sign out (switch account)
</button>
);
}