How can i open a link in a new Tab in NextJS ? i tried this :
<Link href="https://twitter.com/" passHref>
<a target="_blank">
<div className={`${dark ? styles.iconTwitterWhite : styles.iconTwitter} mr-3`} />
</a>
</Link>
It opens the link in a new Tab but i have an ESLint
message saying :
ESLint: The href attribute is required for an anchor to be keyboard accessible. Provide a valid, navigable address as the href value. If you cannot provide an href, but still need the element to resemble a link, use a button and change it with appropriate styles.
Is there another way to do it ?
rel="noopener noreferrer"
to prevent the newly opened tab from being able to modify the original tab maliciously. Regarding the linting issue, it's a known limitation of Next.js<Link>
component. See possible solutions here: github.com/vercel/next.js/issues/5533