Active link detection in Next.js works by checking the current URL path against each link's href. When a user clicks a link, Next.js updates the URL. The NavLink component uses the usePathname hook to get the current path. It compares this path with the link's href. If they match exactly, the component adds an 'active' CSS class to highlight the link. This helps users know which page they are on. The execution table shows how the pathname and href change as the user clicks different links, and when the 'active' class is applied. Beginners often wonder why the active class only appears on exact matches and what happens with subpaths. The code uses strict equality, so only exact matches get the active style. To handle subpaths, the code would need to check if the pathname starts with the href. This visual trace helps learners see how state changes and rendering happen step-by-step in active link detection.