-
Notifications
You must be signed in to change notification settings - Fork 312
feat(core): Add env var to control default prefetch behavior #553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
5 Ignored Deployments
|
78e16c0
to
959800e
Compare
.env.example
Outdated
# 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to prefix this with NEXT_PUBLIC_
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦
959800e
to
b7eacd3
Compare
⚡️🏠 Lighthouse reportWe ran Lighthouse against the changes and produced this report. Here's the summary:
Lighthouse ran against https://catalyst-latest-th6fst05a-bigcommerce-platform.vercel.app/ |
@@ -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'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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? 🤔
Going to close this for now |
What/Why?
Adds support for the
DEFAULT_PREFETCH_BEHAVIOR
environment variable. If set totrue
,Link
components will default toprefetch=true
when aprefetch
prop is not provided. Otherwise, they will default toprefetch=false
, which is the current behavior.Testing
Tested locally, verifying that prefetching is globally disabled when
DEEFAULT_PREFETCH_BEHAVIOR
is any value other thantrue
, and enabled if it is set totrue
.