diff --git a/packages/next/shared/lib/router/router.ts b/packages/next/shared/lib/router/router.ts index 6ffb6e0b619522c..c9c06916706fce6 100644 --- a/packages/next/shared/lib/router/router.ts +++ b/packages/next/shared/lib/router/router.ts @@ -2267,6 +2267,11 @@ export default class Router implements BaseRouter { asPath: string = url, options: PrefetchOptions = {} ): Promise { + // Prefetch is not supported in development mode because it would trigger on-demand-entries + if (process.env.NODE_ENV !== 'production') { + return + } + if (typeof window !== 'undefined' && isBot(window.navigator.userAgent)) { // No prefetches for bots that render the link since they are typically navigating // links via the equivalent of a hard navigation and hence never utilize these @@ -2361,11 +2366,6 @@ export default class Router implements BaseRouter { } } - // Prefetch is not supported in development mode because it would trigger on-demand-entries - if (process.env.NODE_ENV !== 'production') { - return - } - const data = process.env.__NEXT_MIDDLEWARE_PREFETCH === 'strict' ? ({} as any)