I am using next.js, react18 and next-auth. I have a login component that checks the session and displays a login or logout link, depending on you are logged in or not
import Link from 'next/link';
const Login = () => {
const {data: session} = useSession();
if (session) {
return <Link href="#"><a onClick={() => signOut({callbackUrl: `${window.location.origin}`})}>Sign out</a></Link>
} else {
return <Link href="#"><a onClick={() => signIn()}>Log in</a></Link>
}
this used to work as expected, but then I installed react-bootstrap, I changed the links like this
import {Nav} from "react-bootstrap";
return <Nav.Link href="#"><a onClick={() => signOut({callbackUrl: `${window.location.origin}`})}>Sign out</a></Nav.Link>;
return <Nav.Link href="#"><a onClick={() => signIn()}>Log in</a></Nav.Link>;
and I started to get this error
Error: Hydration failed because the initial UI does not match what was rendered on the server.
I know I could downgrade to react 17 or just use the 'next/link' component but I am looking for a workaround before to give up.