Next.js Discord

Discord Forum

Facing problem to fetch data based on current user loggedin in server component in next js v13.4

Unanswered
Dutch posted this in #help-forum
Open in Discord
DutchOP
Hey community I am stuck with a problem in new version of next js v13.4 server component please help me and provide best approach to solve the problem. The problem is I am trying to fetch data from data based on current user details means if I am a user I logged in a website through "log in with google" button then the website stores my data to the data base with some attribute like user id, name, email, profile image, role (Admin/User), access role (normal user/ premium user, etc), then the website shows data which is specific to me which only I can access. In this scenario you noticed user access role and other datas I have to store in something like session to access the data for the fetch query based of user role of other attributes, but in the server component i can't use session for getting user data, so I can't use user data for fetch specific data based on user access role or etc attribute , for using the same thing I have to use Client component insted of Server component, in the next js docs they recommed server component for fetching data, and browser reated task like button click etc you should use client component. They says server component is faster but in this condition I can't use this. Please help me to make best approatch for making this type of website where data fetched and ui customization based on current logged in user access role, should i use client component in entire website with using session or tellme another approatch to use server component as well as...

0 Replies