My decision tree: Using @remix_run
My decision tree:
Using @remix_run? Fetch in loader.
Using @nextjs? Fetch in getServerSideProps/getStaticProps and via swr on client.
Using React Router 6.4? Fetch in the route’s loader prop.
Using Redux? Fetch via rtk query.
Nothing above applies? Use react-query.
Two clarifications:
1. React Router 6.4 isn't here yet, but it adds data support via a new loader prop and looks 🔥: https://beta.reactrouter.com/en/dev/getting-started/data
2. I plan to continue using react-query with React Router 6.4, so I can enjoy react-query's unique benefits like caching.