Next.js Discord

Discord Forum

Re-fetching data when component loads

Answered
Orchard Oriole posted this in #help-forum
Open in Discord
Orchard OrioleOP
i have a navigation and 2 components. one of those components, UserInformation fetches user data and displays it. when i go to the other component and back, the data stays the same (even though its updated in the db)

how can i make sure it re-fetches the data every time? is it possible with a server component like this or does it have to be a client component?
Answered by Ray
I would suggest using react-query/swr
View full answer

10 Replies

Orchard OrioleOP
Anyone?
Orchard OrioleOP
Yes
@Orchard Oriole Yes
try fetching the data client side if you want to prevent the data cache in router cache. because its impossible to disable router cache atm
Orchard OrioleOP
How would I do that?
@Orchard Oriole How would I do that?
I would suggest using react-query/swr
Answer
btw, is seo important for that page?
Orchard OrioleOP
Nope
@Ray I would suggest using react-query/swr
Orchard OrioleOP
I’ll look into it
Thanks