Next.js Discord

Discord Forum

Is there any easy way to check if rendering a component in SSR or RSC in a utility function

Unanswered
Giant ichneumon wasp posted this in #help-forum
Open in Discord
Giant ichneumon waspOP
I want to change how a function works based on whether it's being called in an RSC context or a SSR context Is there an easy way / convenience function? I obviously can't check window, although that helps for splitting RSC/SSR from client rendering.

1 Reply

Giant ichneumon waspOP
This seems like an ok solution, however, if there's a stable function i'd obivously rather use that
const isRSC = Boolean((globalThis as any).AsyncLocalStorage)