https://supertokens.com/ logo
Title
c

Chunkygoo

10/18/2022, 7:02 AM
Lag for SessionAuth
I noticed that when I go to a route protected by SessionAuth, there is a slight delay. Is there a way to show a spinner or something while SessionAuth checks if there is an authenticated user?
r

rp

10/18/2022, 7:14 AM
yea. From the user context, you get a
isLoading
prop. If that's true, you can render a spinner
c

Chunkygoo

10/18/2022, 7:27 AM
I am protecting a NextJs page like this
<SessionAuth>
        <MyComponent />
      </SessionAuth>
r

rp

10/18/2022, 7:27 AM
yea.. so in the MyComponent component, you can get the session context, and from there, get the isLoading prop.
c

Chunkygoo

10/18/2022, 7:27 AM
The page does not allow the use of useSessionContect
r

rp

10/18/2022, 7:28 AM
why not?
c

Chunkygoo

10/18/2022, 7:28 AM
I can use it in MyComponent
But not in the page
because NextJs pages are not components therefore no hooks allowed
r

rp

10/18/2022, 7:29 AM
so wrap your whole page in SessionAuth, and make it into a component
c

Chunkygoo

10/18/2022, 7:51 AM
Ok I will try that, thanks!