I'm currently using next-auth for authentication. I have a piece of code that checks whether a session exists and renders a "signout" button based on that (this page is also SSG):
{session && (
<li>
<Link href="/api/auth/signOut">
<a
onClick={(e) => {
e.preventDefault();
signOut();
}}
>
Sign Out
</a>
</Link>
</li>
)}
However, when I do this, I see a flicker in my nav bar. I would think that there shouldn't be a flicker since the client already knows whether the session exists.
I've looked at the network requests, and I see that a request is made every time I reload the page. Why is this request necessary? Shouldn't the client already know whether a session exists or not without having to make a request?