Data Fetching Patterns for User Session

What approaches do you typically use for data-fetching in multitenant applications built with Next.js 14+? Specifically for managing things like the current organization, user profile, or dynamic navigation links: Do you store some state in the URL (e.g., organization ID)? Do you prefer using a global state management library? Or do you keep it simple with plain RSC (React Server Component) fetching through server actions? I understand the choice depends on the use case, but I’d love to hear your recommendations and what has worked well in your experience.
1 Reply
Ayoub K
Ayoub K5w ago
I don't think you need to store the some state for the (organization ID) either in URL or with help from some library. Whether you use cookies or something else for your auth, the data you get back from the server will be for the authenticated user or org. If you're doing multi org per user, you might want to store the state for your "currentOrg" or "openOrg" or "latestOpenedOrg" or whateveer you want to call it in your database, so that you could redirect the user to that org upon login. In general, if you're doing multi org per user, the best way in my opinion is to store orgId in the URL
Want results from more Discord servers?
Add your server