diff --git a/.env.example b/.env.example index bfb92306c5..3a6a10d4d1 100644 --- a/.env.example +++ b/.env.example @@ -25,3 +25,8 @@ AUTH_SECRET= # https://turbo.build/repo/docs/core-concepts/remote-caching#artifact-integrity-and-authenticity-verification # This can also be generated with `openssl rand -hex 32`, but do not re-use the value from AUTH_SECRET TURBO_REMOTE_CACHE_SIGNATURE_KEY= + +# Controls the default behavior of Link components when a `prefetch` prop is not provided. +# If set to `true`, Link components will default to `prefetch=true`. +# Otherwise, Link components will default to `prefetch=false`. +DEFAULT_PREFETCH_BEHAVIOR=false \ No newline at end of file diff --git a/apps/core/components/link/index.tsx b/apps/core/components/link/index.tsx index 218cba2961..7cd8c496f9 100644 --- a/apps/core/components/link/index.tsx +++ b/apps/core/components/link/index.tsx @@ -9,8 +9,10 @@ type LinkType = Omit, keyof LinkPr children?: React.ReactNode; } & React.RefAttributes; +const prefetchDefault = process.env.DEFAULT_PREFETCH_BEHAVIOR === 'true'; + export const Link = forwardRef, LinkType>( - ({ href, prefetch = false, children, className, ...rest }, ref) => { + ({ href, prefetch = prefetchDefault, children, className, ...rest }, ref) => { return (