//Lib import classes from './Nav.module.css'; import { IconUser, IconLogout } from '@tabler/icons'; import Link from 'next/link'; import { useRouter } from 'next/router'; import { useSession, signOut } from 'next-auth/react'; export default function Nav() { ////Var //Get the current route to light the right Item const router = useRouter(); const currentRoute = router.pathname; const { status, data } = useSession(); //Function const onLogoutClickedHandler = async () => { //This bug is open : https://github.com/nextauthjs/next-auth/issues/1542 //I put redirect to false and redirect with router. //The result on logout click is an ugly piece of page for a few milliseconds before returning to the login page. //It's ugly if you are perfectionist but functional and invisible for most of users while waiting for a next-auth fix. await signOut({ redirect: false }); router.replace('/login'); }; return ( ); }