What is the best way to fetch bootstrap data?
I want to fetch some bootstrap data when a user first loads the app. This data includes feature flags and the list of workspaces of the user and their preferences, etc...
From my understanding of the framework so far, there are multiple ways of doing this:
- Using TanStack Query (or some other library) with client-side caching: However, I would ideally like this to be done on the server-side instead, and preferably just by using the primitives of the router.
- Using beforeLoad with staleTime set to Infinity: This forces me to use a pathless layout specifically for the data that I want to cache, additionally it makes it run twice: once on the server and once on the client, which is not ideal (ideally this would be ran only once, on the server).
- Some other mechanism that I do not know of? I was considering onEnter but then I would have to save the context outside of the router. I feel like there is a missing Route Option that could resolve this issue though.
So my question is: What is the idiomatic way of doing this in Start? And how have others resolve it so far?
From my understanding of the framework so far, there are multiple ways of doing this:
- Using TanStack Query (or some other library) with client-side caching: However, I would ideally like this to be done on the server-side instead, and preferably just by using the primitives of the router.
- Using beforeLoad with staleTime set to Infinity: This forces me to use a pathless layout specifically for the data that I want to cache, additionally it makes it run twice: once on the server and once on the client, which is not ideal (ideally this would be ran only once, on the server).
- Some other mechanism that I do not know of? I was considering onEnter but then I would have to save the context outside of the router. I feel like there is a missing Route Option that could resolve this issue though.
So my question is: What is the idiomatic way of doing this in Start? And how have others resolve it so far?