TanStackT
TanStack2y ago
7 replies
moderate-tomato

Is there a way to use hooks in loader function?

I have set up an useAxios hook for bearer token, however I am unable to use that in loader functions, is there a workaround for this?

For now, I have saved the token in router context, and I am passing that to a custom fetcher to avoid sending auth header explicitly for every request.
Was this page helpful?