Next.js Discord

Discord Forum

Load Script after NextAuth session available

Unanswered
American Crocodile posted this in #help-forum
Open in Discord
Avatar
American CrocodileOP
I am loading an external Pendo script that depends on session user data for initialization. Using the strategy="afterInteractive", I am still having issues with the session not being available when the script initializes, so the user data is null.

Is there a way to check for session before loading the Script? Or to set a timeout before loading the script?

This is in my main layout.tsx which is a server component.

2 Replies

Avatar
Yi Lon Ma
extract the logic to render the script into another component and use the useSession hook
then render conditionally