You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, thank you for providing a fantastic search tool for the open-source community.
I recently implemented a search feature on my blog using Next.js. However, I noticed that DocSearch only performs hard navigation. This results in unnecessary full-page refreshes when navigating to other pages within my blog using Next.js, which negatively impacts the user experience.
I would like to request support for Next.js's soft navigation by utilizing the <Link> component.
Describe the solution
The current Hit.jsx file looks like below. Adding an option to use the <Link> component would be a good solution. (The following code is just pseudocode and may not be accurate.)
importReactfrom'react';importLinkfrom'next/link';importtype{InternalDocSearchHit,StoredDocSearchHit}from'./types';interfaceHitProps{
hit: InternalDocSearchHit|StoredDocSearchHit;// Defines the type of the `hit` prop
children: React.ReactNode;// Specifies that `children` can be any valid React nodeoptions?: {softNavigation: boolean}}
export functionHit({ hit, children, options }: HitProps): JSX.Element{return(option.softNavigation
? (<Linkhref={hit.url}>{/* For Next.js 12 and below, explicitly wrap children in an <a> tag */}{/* <a>{children}</a> */}{/* For Next.js 13 and above, the <a> tag is no longer required */}{children}</Link>)
: (<ahref={hit.url}>{children}</a>));}
Alternatives you've considered
This is the best approach I can think of. If anyone has other ideas, please feel free to suggest them.
Thank you!
The text was updated successfully, but these errors were encountered:
Describe the problem
Hello, thank you for providing a fantastic search tool for the open-source community.
I recently implemented a search feature on my blog using Next.js. However, I noticed that DocSearch only performs hard navigation. This results in unnecessary full-page refreshes when navigating to other pages within my blog using Next.js, which negatively impacts the user experience.
I would like to request support for Next.js's soft navigation by utilizing the
<Link>
component.Describe the solution
The current
Hit.jsx
file looks like below. Adding an option to use the<Link>
component would be a good solution. (The following code is just pseudocode and may not be accurate.)Alternatives you've considered
This is the best approach I can think of. If anyone has other ideas, please feel free to suggest them.
Thank you!
The text was updated successfully, but these errors were encountered: