Next.js Discord

Discord Forum

Best practices - how to fetch data from external backend, client or server component

Unanswered
Forest yellowjacket posted this in #help-forum
Open in Discord
Forest yellowjacketOP
I have saved data about the user in the next-auth session. Data contains JWT, userId and role. I need to fetch data from my external Java/Springboot backend - address http://localhost:8080/brewstation/batches/{userId}. How to do it with best practices? I faced a problem when I can't use Async and Await in the Client component ('use client') but already I can't to use the useSession() function when I don't have 'use client' in the component. So is good to fetch data in server component or in client component? How to do that?

0 Replies