Disable link prefetching in preview mode #29058
Replies: 5 comments
-
Would love this. With preview enabled our server is getting hit with over 20 simultaneous uncached serverless requests which take many seconds to resolve. |
Beta Was this translation helpful? Give feedback.
-
The more I think about it the less I understand the reason why link prefetching is enabled in preview mode. Maybe @timneutkens can shed some light on the subject since they closed this issue. |
Beta Was this translation helpful? Give feedback.
-
@hatsumatsu while this function doesn't get to production, what I recommend you is to abstract the next link with your own abstraction of it, then you can do this verification by yourself, and other ones that we need sometimes. |
Beta Was this translation helpful? Give feedback.
-
@timneutkens Can I work and send a PR with the feature described here? Or do you think this isn't necessary to be out-of-box? |
Beta Was this translation helpful? Give feedback.
-
And actually documentation is also rather confusing, because it says:
|
Beta Was this translation helpful? Give feedback.
-
Describe the feature you'd like to request
When using next's preview mode links via next/link are automatically prefetched as normal.
Since preview mode bypasses SSG and ISR, both the prefetch requests and the actual requests when clicking a link are server-rendered on request. this results in a high number of SSR requests in preview mode causing high load on external APIs and hosting services like vercel.
Describe the solution you'd like
Automatically (or via config) disable link prefetching in preview mode.
Describe alternatives you've considered
An alternative can be passing next/routers isPreview value to the prefetch prop of next/link. but setting prefetch={false} on next/link still prefetches on mouseenter.
Beta Was this translation helpful? Give feedback.
All reactions