Performance: Link component for client navigation
This affects page load speed and interaction responsiveness by enabling client-side navigation without full page reloads.
import Link from 'next/link'; export default function Nav() { return <Link href="/about">About</Link>; }
import React from 'react'; export default function Nav() { return <a href="/about">About</a>; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Plain <a> tag navigation | Full DOM reload | Multiple reflows due to full page reload | High paint cost from re-rendering entire page | [X] Bad |
| Next.js Link component | Partial DOM update | Single reflow for updated components | Lower paint cost by reusing DOM | [OK] Good |
Link component in Next.js?Link component?href prop for the destination and wraps an <a> tag for accessibility and styling.href and wraps <a> correctly. <Link to='/about'>About</Link> uses to which is React Router syntax, not Next.js. <a href='/about'>About</a> is a plain anchor tag without Link, so no client navigation. <Link url='/about'><a>About</a></Link> uses url which is invalid.import Link from 'next/link';
export default function Home() {
return (
<Link href='/contact'><a>Contact Us</a></Link>
);
}href='/contact' and wraps the text inside <a>, which is the correct pattern. No errors or missing props.import Link from 'next/link';
export default function Nav() {
return (
<Link href='/services'>Services</Link>
);
}<a> tag for accessibility and styling.<a> tag, which is incorrect and can cause accessibility issues.href prop and wrap an <a> tag for accessibility and client navigation.href and wraps text in <a>. uses plain anchors without Link, causing full reloads. uses to which is invalid in Next.js. uses <span> instead of <a>, breaking accessibility and styling.Pass the test and this pattern moves unknown