Skip to content

Recommended way to fetch APIs for multiple components on 1 page #2092

Closed Answered by sergiodxa
ConnorVO asked this question in Q&A
Discussion options

You must be logged in to vote

You can:

  1. Fetch everything in parallel (Promise.all) in the loader, the problem here is if you want to revalidate the loader data it will fetch everything not only one widget of the dashboard.
  2. Use the useFetcher hook to fetch client-side inside a useEffect, this will give you more control of the data loading but you will lose SSR.

I think for a dashboard SSR may not be that useful so using useFetcher is probably going to be better if the dashboard is too customizable, you could still fetch some things no the route loader tho, like authenticated users, permission, what widgets to show, etc.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ConnorVO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants