How to share data from components in two different routes in next14 app router ? #63761
Unanswered
manacy-keyvalue
asked this question in
App Router
Replies: 1 comment
-
i have similar issue on my use cases. How to handle this? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm using next 14 app router. I have a use-case where i need to share data from components in two different routes. In page router/react, we used to keep the data in global store and re-use that data. But with app router in next 14, i came across documentation where we are only supposed to create one store per request.
"No global stores - Because the store should not be shared across requests, it should not be defined as a global variable. Instead, the store should be created per request."
But the use-case still exists in my project. How can i handle this use-case adhering to the nextjs docs to follow single store per request.
The use case involves a form-filling feature (Feature A) where users need to select an item from a separate route. Upon selecting an item, users return to the form in Feature A, where the selected item needs to be populated along with any previously entered form data. This requires seamlessly transferring data between routes and preserving form state across navigations.
How can I maintain form data and a selected item across route navigations in Next.js 14 without violating the recommendation of a single store per request ?
Beta Was this translation helpful? Give feedback.
All reactions