Is auth check on beforeLoad
a good idea?
#3339
Replies: 3 comments 2 replies
-
This is a question that I also have. Preload seemed to trigger way more additional requests than I was expecting. I turned preload off for the time being, but would love some clarity around this as well. |
Beta Was this translation helpful? Give feedback.
-
Tanstack query to the rescue , call the get session useQuery outside the router provider and pass in the value through the router context then check the plain value in the before load instead of awaiting there |
Beta Was this translation helpful? Give feedback.
-
The docs are severely lacking in this area. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
By following documentation we can learn the user auth check should happen on
beforeLoad
function.Something like this:
However seems like this approach is checking the auth state a way too many times.
If I use
<Link />
(wherepreload
has default valuetrue
) I am ending up with following effect:https://share.cleanshot.com/3tkTWQfM

Whats your approach to avoid that effect?
Beta Was this translation helpful? Give feedback.
All reactions