Root loader staleTime behaviour

I have a server-function that returns the user theme (based on cookies) being called in my
__root
layout. This should only need to be fetched on the first load, so I thought I could set staleTime to some high value, but looking at the logs and network requests the server-function call is still being made on every navigation and pre-fetch.

e.g.:

// __root.tsx
// ...
  loader: async ({ context }) => {
    const theme = await getTheme();
    return {
      userId: context.userId,
      theme,
    };
  },
  staleTime: 30_000,


I would expect getTheme not to be called more than once every 30 seconds, but it's called on every navigation still?
Was this page helpful?