React Easy technical 1 views 1 min read

What is the difference between Link, NavLink, and `<a>`?

Peer-reviewed by HireXTech Technical Panel • Updated for 2025/2026 hiring • Editorial standards
Practise this track
Interviewer Expectations for this Question
01
Core Competency

Assesses fundamental understanding of React conventions, runtime behavior, and memory/performance considerations.

02
Evaluation Criteria

Hiring managers look for precision, avoidance of ambiguous jargon, and ability to explain trade-offs under real production conditions.

Comprehensive Model Answer Verified Solution

All three render an anchor tag in the DOM, but they behave very differently when clicked:

| Aspect | <a href> | <Link to> | <NavLink to> |
| --- | --- | --- | --- |
| Navigation | Full page reload — browser makes a fresh request and the whole app (JS, CSS) reloads | Client-side navigation via History API — no reload, app state is preserved | Same as Link — client-side, no reload |
| Active styling | None built-in | None built-in | Automatically knows if it matches the current URL and exposes that via a class/style/children render function |
| Typical use | Linking to external sites/domains outside the app | Regular in-app navigation (e.g., a card linking to a detail page) | Navigation menus/tabs where you need to highlight the current section |

     import { Link, NavLink } from "react-router-dom";

     // Plain in-app link — no active-state awareness
     <Link to="/about">About</Link>;

     // NavLink automatically applies the "active" class (or your own style function)
     // when the current URL matches "/dashboard"
     <NavLink
       to="/dashboard"
       className={({ isActive }) => (isActive ? "nav-link active" : "nav-link")}
     >
       Dashboard
     </NavLink>;

     // Plain <a> — causes a full browser navigation/reload, breaks SPA behavior
     <a href="/dashboard">Dashboard (avoid for in-app links)</a>;
     

Rule of thumb: use <Link>/<NavLink> for any route inside your React Router tree, and reserve a plain <a href> for links leaving your app (external URLs, mailto:, downloadable files) or for non-SPA full-reload cases.

Candidate Response Strategy & Interview Tips

  1. Start with a concise one-sentence summary: Deliver a direct, confident answer first before expanding into nuances.
  2. Demonstrate real-world trade-offs: Discuss where this approach excels and when you would avoid it in production systems.
  3. Discuss complexity & edge cases: Proactively explain time/space complexity or boundary conditions (null values, scale limits).
  4. Prepare for interviewer follow-ups: Technical hiring panels frequently probe deeper into concurrency, backward compatibility, or alternative libraries.
Related Topics & Skills
Spotted an error or have an alternative solution?