Next.js Discord

Discord Forum

User Data Best Practice

Unanswered
Lilac posted this in #help-forum
Open in Discord
LilacOP
Hey guys, I don't have any code to share but I'm wondering on what's the best way to handle user specific data.

Lets imagine we have a widget that displays user specific data, meaning that you would need to attach headers or cookies so that you pass authentication.

This will completely opt you out of catching.

Additionally, if done with Graphql it would break the request memorization, due to it being a post a POST request.

So here is the question, if I need to use that data in multiple pages and/or components, would it make more sense to cache the user specific data on the client rather than always make a request to a service?

I'm kind of wondering if this won't lead to a 'use client' application if there is a lot of user specific data on it.

2 Replies

You don't have to cache on the client, you could look into the unstable_cache() function from Next.js at your own risk.
LilacOP
@Plague I did but I'm wondering if someone might have some better alternatives to it.

I mean for a large production app it would be unwise to use experimental features.

But based on your response, if I want to not make a lot of request I should cache it on the client and have my components be client components.