Is there a way to determine whether a file or function is being executed as part of a React Server Component or a client component (use client;
)?
Asked
Active
Viewed 49 times
0
-
may you give a final goal? do you want to reuse the same (utility?) function across server- and client-components? – skyboyer Aug 14 '23 at 06:55
-
yes I would like to provide a i18n helper which reads the context only when used inside client components – jantimon Aug 14 '23 at 07:54
-
I understand that's not what your post is about but might it be possible to use [next-intl](https://www.smashingmagazine.com/2023/03/internationalization-nextjs-13-react-server-components/) package? – skyboyer Aug 14 '23 at 12:12
-
1thanks that's a nice library :) it's just that we built our own library with a better runtime performance and code splitting logic – jantimon Aug 14 '23 at 23:19