Next.js Discord

Discord Forum

How do you handle getting data on client components?

Unanswered
Alligator mississippiensis posted this in #help-forum
Open in Discord
Alligator mississippiensisOP
Okay I don't understand next a bit. Server components are self explanatory you can get data there no problem, just execute server code as you need. But client components become a bit more challenging, as I understand you should always try to send data through server components, there's also the server actions, but as I understand they are more designed for data mutations and they don't offer stuff like loading state, error, etc... But sometimes you need to get data on button click, or some other edge case, so what's left is to use the same stuff you would use in a vanilla react application, create an api endpoint and fetch using useEffect or some other library. Am I thinking correctly?

0 Replies