Next.js Discord

Discord Forum

Question with Context Api on Next

Answered
Channel catfish posted this in #help-forum
Open in Discord
Channel catfishOP
I'm using React Context Api just to save some user infos. It's my first time using it.
I have finished the config but I notice that when I refresh the page (using F5) the storage value is refreshed to default.
Is this the correct behavior? The storage value shouldn't be the same even using F5?

If I want to keep the information even with F5 I need to set the storege in any page?

I follow the next github example: https://github.com/vercel/next.js/tree/canary/examples/with-context-api

About the images:

The first one is when I open the page the first time. It get the storage value and try to verify the user's token, them update the user information. (This behavior is Ok for me)
The second is when I go to a new page using a Link (from next/link)
The third is when I do F5 on the second page.
Answered by Yi Lon Ma
yes this is the correct behavior
View full answer

3 Replies

yes this is the correct behavior
Answer
you need to implement your own saving mechanism using local storage or similar
@Yi Lon Ma yes this is the correct behavior
Channel catfishOP
Thank you. I'm trying to "correct" this for a week and it isn't even an error ahhaha