Using Effect-Atom with TanStack Router for authenticated routes
I'm using tanstack router and I am looking to set up some authenticated routes, while trying to lean on effect-atom for all state management. I can do this using
And then I use the
beforeLoad or go the context route, but just for the sake of it, I'm doing it on beforeLoad. This then requires me to be able to get the value of an atom in an async function. From looking at the API docs i've managed to cobble together something like this:And then I use the
getAtomResult utility function in the root route in beforeLoad. Is this the recommended way to go about this or is there some more straight-forward way to do this?