You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to propose adding a request batching capability to SWR that would significantly improve performance for data-intensive applications. After using SWR extensively, I've noticed that components rendering in quick succession often trigger multiple network requests that could be consolidated.
The Problem
When multiple components mount nearly simultaneously (like in dashboards or lists), they often request data independently, creating a "request waterfall" that:
Increases network overhead with many small requests
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello SWR team,
I'd like to propose adding a request batching capability to SWR that would significantly improve performance for data-intensive applications. After using SWR extensively, I've noticed that components rendering in quick succession often trigger multiple network requests that could be consolidated.
The Problem
When multiple components mount nearly simultaneously (like in dashboards or lists), they often request data independently, creating a "request waterfall" that:
Proposed Solution
I'd like to contribute a request batching system that:
This would integrate with SWR's middleware system, exposing:
useSWRBatch
hook for direct usecreateBatchMiddleware
factory for global configurationExample Usage
Technical Approach
The implementation would follow SWR's patterns:
_internal/types.ts
for batch options_internal/utils/batch.ts
batch/index.ts
fileBenefits
I've already sketched the implementation and would be happy to share more details or create a proof-of-concept PR if there's interest in this feature.
What do you think? Would this be a valuable addition to SWR?
Beta Was this translation helpful? Give feedback.
All reactions