Next.js Discord

Discord Forum

Prevent over-prefetching on next/link

Unanswered
Saltwater Crocodile posted this in #help-forum
Open in Discord
Saltwater CrocodileOP
I have about 500-1000 <Link> components on an SSR-generated page. I'm currently using the App Directory.

When I scroll too quickly, I end up prefetching all of them which ends up causing a bug I cannot reproduce locally. https://legacy.reactjs.org/docs/error-decoder.html/?invariant=185

At the moment I have eliminated prefetching, but wondering if there are any recommended approaches to this.

If not, a dream world would be introducing an optional debounce, creating a prioritized queue, or limiting the prefetch requests inflight. Just a few thoughts but I'm surprised I haven't found more people running into this problem.

0 Replies