TanStackT
TanStack16mo ago
6 replies
broad-emerald

Can I make a common loader for few components?

I have a backend server from which I request user details, and it successfully sends the user details. However, the issue is that I only get the user details for specific routes where I use a loader. I want to access the user details on every authenticated route.

For example, if I navigate to localhost:5173/, I get the user details because I'm using a loader there. But if I try to access localhost:5173/test or localhost:5173/test2, I don't get the user details, even though all three routes are authenticated. This happens because I haven't used a loader in the test or test2 components.

I would like to implement a central loader that can fetch the user details for every authenticated route. Can you help resolve this issue?

Would you like help with the implementation details for a central loader solution or do you have any other alternative solution?
image.png
image.png
image.png
image.png
Was this page helpful?