Skip to content
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

[sitecore-jss-nextjs]: Update Link.tsx to support next/link's prefetch property #2039

Merged
merged 2 commits into from
Feb 25, 2025

Conversation

chrissnyder2337
Copy link
Contributor

@chrissnyder2337 chrissnyder2337 commented Feb 7, 2025

The Link component in the sitecore-jss-nextjs package does not currently support the prefetch prop from Next.js's <Link/> component. This limitation prevents developers from conditionally utilizing Next.js's prefetching capabilities for internal links. Prefetching can improve page load performance by preloading linked pages in the background; however, this can increase hosting costs.

See https://nextjs.org/docs/pages/api-reference/components/link#prefetch

Description / Motivation

Without the prefetch property, Next.js defaults to prefetching being enabled. This change exposes the property to allow it to be enabled or disabled as needed. Some applications may prefer to disable it on some links to reduce overall hosting usage. According to the Vercel documentation on optimizing edge requests, reducing the amount of prefetching can decrease the number of requests made to your site, which can help manage hosting costs.

Testing Details

  • Unit Test Added
  • Manual Test/Other (Please elaborate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

This allows users to disable prefetching on links. 

Without a change like this, it is not possible to disable prefetching

See https://nextjs.org/docs/pages/api-reference/components/link#prefetch
@Chris1415
Copy link

Chris1415 commented Feb 8, 2025

@art-alexeyenko @illiakovalenko @yavorsk any chance one of you could have a quick look?

@chrissnyder2337 chrissnyder2337 changed the title Update Link.tsx to support next/link's prefetch property [sitecore-jss-nextjs]: Update Link.tsx to support next/link's prefetch property Feb 10, 2025
@yavorsk
Copy link
Contributor

yavorsk commented Feb 12, 2025

Thanks for the contribution @chrissnyder2337 ! I added a ticket to review and add unit tests

Copy link
Contributor

@illiakovalenko illiakovalenko left a comment

Choose a reason for hiding this comment

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

@chrissnyder2337 Thank you for your contribution! Your effort is appreciated

@illiakovalenko illiakovalenko merged commit f488bc2 into Sitecore:dev Feb 25, 2025
1 check passed
@illiakovalenko illiakovalenko mentioned this pull request Feb 25, 2025
8 tasks
illiakovalenko added a commit that referenced this pull request Feb 25, 2025
* Added unit tests
* Updated CHANGELOG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants