What is the difference between Link and NavLink? Feature Link NavLink Purpose Navigate between pages Navigation with active styling
ctive
style
No built-in active
style
utomatically adds an active class when the route is
ctive
Use case Basic navigation For creating navigation menus with active links (e.g.,
highlighting the active link)
Example of NavLink:
import { NavLink } from 'react-router-dom';
function Navbar() {
return (
<nav>
<NavLink to="/" activeClassName="active">Home</NavLink>
<NavLink to="/about" activeClassName="active">About</NavLink>
</nav>
);
}