#Disable prefetch for specific page

1 messages · Page 1 of 1 (latest)

thick knoll
#

Is there a way to globally disable prefetching for a specific page, for example I have a /logout page, which handles logout server side, but I would like prefetching to be disabled for this route without having to pass prefetch={false} to the <Link /> component everywere

viral quailBOT
#

Hi @thick knoll. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

I'm sorry, but the knowledge sources do not mention a built-in way to globally disable prefetching for a specific route or page in Next.js. The documented approach is to set prefetch={false} on each <Link /> that points to the route you want to exclude from prefetching, such as /logout Next.js Link prefetch (App Router) Next.js Link prefetch (Pages Router).

If you want to ensure prefetching is disabled for a specific route everywhere, you would need to consistently add prefetch={false} to all <Link /> components targeting that route. There is no configuration or API in the provided documentation that allows you to set this globally for a specific path.

If you want to avoid this repetition, you could create a custom Link component that automatically sets prefetch={false} for certain routes, but this pattern is not described in the official documentation or knowledge sources.

In summary: There is no built-in or documented way to globally disable prefetching for a specific page; you must use prefetch={false} on each relevant <Link /> Next.js Link prefetch (App Router) Next.js Link prefetch (Pages Router).

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: