Next.js Discord

Discord Forum

Invalidate "cache()" from react?

Answered
Galgo Español posted this in #help-forum
Open in Discord
Galgo EspañolOP
I'm trying to make it so when you either login or logout the user data fetched in my layout is refetched.
I've tried to refresh the page using the router and various tactics to do hard-navigation but none of them seemed to work :/
This didn't work for me:
https://github.com/vercel/next.js/discussions/44149
I'm using react's cache function to fetch if the user is logged in or not in my layout file
Answered by Galgo Español
Just needed to await the fetch to the logout froute before refreshing
View full answer

3 Replies

Galgo EspañolOP
Whoops!
It was actually quite easy to fix :)
Galgo EspañolOP
Just needed to await the fetch to the logout froute before refreshing
Answer