Where search validation happens?
I have many cards when I click on it it gets highlighted. The logic is simple, I get the selected id from hook route.useSearch.
I use useNavigate().navigate() to set the active id
The problem is when I set the internet to slow on dev tools the cards take a lot of time to get highlighted.
Does search validation happen on server?
If so, what is the solution to get this on client?
12 Replies
genetic-orangeOP•8mo ago
I used the example from the Clerk docs to implement authentication, but I think there's a problem. If I use a server function to verify whether the user is authenticated before loading a page, the function gets called every time my search parameters change, making navigation slow.
If I move the server function to the loader and set a staleTime, the issue is resolved. However, this causes me to lose authentication information in the context.
If I move the server function to the loader and set a staleTime, the issue is resolved. However, this causes me to lose authentication information in the context.
ugly-tan•8mo ago
please provide a minimal complete example
genetic-orangeOP•8mo ago
Every time I click on change params one call to authStateFn is made. It affects directly the perfomance of client aplication. I click and sometime it takes some time to re-render the page .

genetic-orangeOP•8mo ago
I tried the solution using hooks, but how to pass context to it?

ugly-tan•8mo ago
can you please provide a minimal complete example?
genetic-orangeOP•8mo ago
If you execute this code you're going to see the problem. The button get its color only when the serverFunction is completed executed

ugly-tan•8mo ago
can't execute a picture, can I? 😄
can you please share a complete reproducer, e.g. as a github repo?
genetic-orangeOP•8mo ago
ugly-tan•8mo ago
but maybe that's not even necessary really here
beforeLoad
executes upon each request
if you dont want to perform some backend call each time, you need to cache the resultgenetic-orangeOP•8mo ago
In my case I’m using the example on clerks docs. They recommend this approach
But then I realized this problem
I’d like to implement a client solution using hooks.
ugly-tan•8mo ago
GitHub
Changed auth architecture for clerk by MiltonAkash · Pull Request #...
Current architecture using beforeLoad fetched auth on every route change making lag on navigation resulting bad UX
genetic-orangeOP•8mo ago
But I can’t inject context with </StartClient>
Omg, I tried this solution but I kept looking for a solution where I could have the auth information on context
I'll just use the provid hooks from clerk
Thank you too much. You helped me a lot
provided