What is the way to initialise libraries like LogRocket after the new NextJS 13 came out with the experimental app
directory? For example, I used to initialise it using the useEffect
script inside the _app.tsx
file like so:
import LogRocket from 'logrocket';
useEffect(() => {
if (process.env.NODE_ENV === 'production') {
LogRocket.init(process.env.NEXT_PUBLIC_LOGROCKET_APP_ID);
}, []);
Now, NextJS complains the useEffect
hook can not be called on a server-side component, as I am trying to run this code from the layout.tsx
. What is the new way to inject scripts like this globally?