Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
NEXT_PUBLIC_DEFAULT_PREFETCH_BEHAVIOR=false
4 changes: 3 additions & 1 deletion apps/core/components/link/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ type LinkType = Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof LinkPr
children?: React.ReactNode;
} & React.RefAttributes<HTMLAnchorElement>;

const prefetchDefault = process.env.DEFAULT_PREFETCH_BEHAVIOR === 'true';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const prefetchDefault = process.env.DEFAULT_PREFETCH_BEHAVIOR === 'true';
const prefetchDefault = process.env.NEXT_PUBLIC_DEFAULT_PREFETCH_BEHAVIOR === 'true';

Or does next remove NEXT_PUBLIC by default? 🤔


export const Link = forwardRef<ElementRef<'a'>, LinkType>(
({ href, prefetch = false, children, className, ...rest }, ref) => {
({ href, prefetch = prefetchDefault, children, className, ...rest }, ref) => {
return (
<NextLink
className={cn(
Expand Down