Keep fetched data between pages
Answered
Sw1ndler posted this in #help-forum
Sw1ndlerOP
As seen here, when I navigate to a new page, there is a new request to get user data
Is there a way to use the previously fetched data?
https://lemonhost.pics/Sw1ndler/DQdXbm7ySm
Is there a way to use the previously fetched data?
https://lemonhost.pics/Sw1ndler/DQdXbm7ySm
Answered by New Guinea Freshwater Crocodile
idk then, im new and only know about app router. but if you're not using swr look into that cuz you will be able to cache these user info and invalidate it on logout or depending on some other criteria
10 Replies
New Guinea Freshwater Crocodile
app or pages router?
Sw1ndlerOP
pages
im considering using localstorage but I assume there is a better alternative
New Guinea Freshwater Crocodile
idk then, im new and only know about app router. but if you're not using swr look into that cuz you will be able to cache these user info and invalidate it on logout or depending on some other criteria
Answer
Sw1ndlerOP
swr seems like a good idea, does it persisent between pages though?
New Guinea Freshwater Crocodile
yeah but i think you may need to disable some of the automatic revalidations
Sw1ndlerOP
automatic revalidations seems like a good idea to me
New Guinea Freshwater Crocodile
Sw1ndlerOP
oh i see
thanks for the help, ill check it out