SignOut function doesn't immediately re-invoke session change
Hi, everyone
I am currently implement auth in my project
I followed the quick start from docs and it went smoothly
But when I implement sign out and click it, it doesn't immediately show logged out display instead I have to reload the page to see the change?
Here's my
auth.ts
file:
Thx for anyone's help!!!Solution:Jump to solution
```ts
export default async function MainLayout({
children,
}: Readonly<{...
8 Replies
it only refresh automatically when it's a state change. Use
router.refresh
after sign out or redirectI used the
router.refresh
or redirect
, but it still didn't reflect immediate change in my user-dropdown.tsx
Here's some reference files:
user-dropdown.tsx
auth.ts
window.location.reload() should be work
Im getting same issue btw if i find a better way i will write it
It could be cause your dropdown is server rendered and on refresh or redirect it's not getting re-rendered
because you using server rendered layout and client side header component
Solution
This is my code
layout not rerendering
thats why
ill switch to client side session
@JWW
Appreciate your help, but this approach will show as non-logged in initial for a while then turn into real logged in state
This approach can fit into my project, thx for your help