Sharing User Data Between Server Components of Different Pages in Next.js 14 #67330
Replies: 2 comments 1 reply
-
sharing-data-between-components The code looks like the following:
|
Beta Was this translation helpful? Give feedback.
-
I know this is late, but if you use for more information about request memoization, see https://nextjs.org/docs/app/building-your-application/caching#request-memoization also see https://nextjs.org/docs/app/building-your-application/caching#react-cache-function |
Beta Was this translation helpful? Give feedback.
-
I am using Next.js 14 with the app router. In my main layout file, I am fetching user data using a server component and then sharing that data with a client component. I have a context provider that passes this data to the context, allowing me to easily access the user data across all client components on different pages.
However, I am facing an issue: while I can easily access the user data from the context in client components on all pages, I need to access this data in a few server components on other pages as well. How can I achieve this? Should I use cookies on the server side for this, or is there a better approach?
Beta Was this translation helpful? Give feedback.
All reactions