Is there a more idiomatic way to do this? Getting Auth Data from Server and Client
So, I am using better auth and Start. I want to eliminate any flicker. that means checking auth status in loaders, but if the user signs out (or signs in) since this is also a SPA, we should use client data as well. That lead me to do the following
in
This gets the data into the root loader. since I check auth status on every page (at the very least, to know whether or not to show the sign in or sign out buttons), I set the staleTime to 60 seconds to slow down unnecesary requests to the database
Then I created a custom hook
now I have a flicker free ui, but is there a more idiomatic way to do this?
in
routes/__root.tsx:This gets the data into the root loader. since I check auth status on every page (at the very least, to know whether or not to show the sign in or sign out buttons), I set the staleTime to 60 seconds to slow down unnecesary requests to the database
Then I created a custom hook
isPending is annoyingly false on servers, so I have to check if we are in a server context or pending on client data. if that is the case, I use the server data from the root loader above. otherwise, we can use clientDatanow I have a flicker free ui, but is there a more idiomatic way to do this?