Skip to content

How to open Link in new tab? #15486

Answered by paambaati
naseef0 asked this question in Help
Jul 26, 2020 · 5 answers · 18 replies
Discussion options

You must be logged in to vote

EDIT: See the response from @Tylerian below.

Adding the passHref prop to your <Link> component should solve this.

<Link href={{ pathname: "/product-details", query: { id: product.id }, }} passHref> <a target="_blank" rel="noreferrer"> <img className="img-fluid" src={getImageUrlBySize(imageUrl, 3, mimeType)} alt={productName} onError={(e) => onImageError(e)} /> </a> </Link>

Further reading — https://nextjs.org/docs/api-reference/next/link#forcing-link-to-expose-href-to-its-child

Replies: 5 suggested answers 18 replies

Comment options

You must be logged in to vote
4 replies
@Tylerian
Comment options

@paambaati
Comment options

@DWMiller
Comment options

@srflp
Comment options

Answer selected by naseef0
Comment options

You must be logged in to vote
11 replies
@lingdocs
Comment options

@hypnoboutique
Comment options

@anguskeatinge
Comment options

@hypnoboutique
Comment options

@anguskeatinge
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@jeremybarthoux
Comment options

@leerob
Comment options

@srflp
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet