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
{{ message }}
Repository navigation
Public API for the prefetch scheduler (custom prefetching via link:prefetch) #36655
Hey! The new prefetch scheduler in 4.6 is very cool. Could we get a public API for it, so custom prefetching hooked on link:prefetch can go through it too?
Here's my use case, simplified. Our pages load data with TanStack Query, and each page declares which queries it needs:
Right now these requests go out right away, outside the scheduler, so they don't get the throttling, deduplication or cancellation on navigation. It works if I use usePrefetchScheduler and prefetchGroup from #app/internal/*, but those are internal:
import{usePrefetchScheduler}from'#app/internal/prefetch-scheduler'import{prefetchGroup}from'#app/internal/prefetch-util'usePrefetchScheduler().schedule({key: `query:${url}`,priority: 'payload',scope: 'navigation',group: prefetchGroup(url),// keeps the prefetch alive when navigating to that pagerun: (signal)=>{signal.addEventListener('abort',()=>queryClient.cancelQueries(/* ... */))returnPromise.all(queries.map((query)=>queryClient.prefetchQuery(query)))},})
A public version of this would be great.
Additional information
Would you be willing to help implement this feature?
Activity