Lag for SessionAuth
c
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
yea. From the user context, you get a
isLoading
prop. If that's true, you can render a spinner
c
I am protecting a NextJs page like this
Copy code
<SessionAuth>
        <MyComponent />
      </SessionAuth>
r
yea.. so in the MyComponent component, you can get the session context, and from there, get the isLoading prop.
c
The page does not allow the use of useSessionContect
r
why not?
c
I can use it in MyComponent
But not in the page
because NextJs pages are not components therefore no hooks allowed
r
so wrap your whole page in SessionAuth, and make it into a component
c
Ok I will try that, thanks!