Make snapshot of page state in Next.js #14765
-
Hi everyone! I want to switch between routes, but keeping all the states on the page so that I can return to page without loosing it's state. I understand that I need to use initalProps at the top level. But this is only suitable for simple cases. Let's take an example where there're hundreds of states on a page with different levels of hierarchy. Is it possible to make a snapshot of all page states? I look towards memo from React. Also, I think Redux would help me, but I don't use it in the application at all and it's one more dependency. Perhaps this can be solved using the Context Api. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
You mean something like check user login? I use localstorage and api to check user auths. Sorry if my cmt not relate. |
Beta Was this translation helpful? Give feedback.
-
@AlexanderVishnevsky you could indeed achieve what you describe by using context, and also share the same context across pages by using a Context Provider in your |
Beta Was this translation helpful? Give feedback.
@AlexanderVishnevsky you could indeed achieve what you describe by using context, and also share the same context across pages by using a Context Provider in your
_app.js
anduseContext
anywhere you want to access its data.