Make the agent use the existing Link component, not a raw <a>, for internal routes
The agent adds a “Back to settings” control as <a href="/settings"> . The app already has a Link (or RouterLink , or Next.js Link ) that prefetches, keeps the client transition, and applies the active class from the design system. The raw anchor does a full reload, loses draft state on the page, and looks unstyled for a frame. I’ve started treating a raw <a> to an internal path as a merge…
The agent should utilize the existing Link component instead of employing a raw anchor (<a>) for internal routes within the application. The Link component, or its variants such as RouterLink or Next.js Link, offers several advantages over a raw <a> tag. It prefetches pages, maintains client transitions, and applies active classes according to the design system.
Using a raw <a> for internal paths results in full page reloads, loss of draft state, and an unstyled appearance for a brief period after navigation. External URLs, mailto links, and file downloads can still use raw anchors, but internal paths should be handled with the shared Link component. The raw anchor may inadvertently sneak in due to HTML examples being present in millions of instances.
Its use will not preserve the app's scroll restoration, locale prefix, base path, or analytics features that are inherently included in the shared Link component. Implementing a navigation policy where internal routes utilize the shared Link, while external URLs use either an <a> tag or a custom ExternalLink with the appropriate rel attributes, ensures a consistent user experience and maintains application performance.
Reviewing the codebase for raw <a> tags and replacing them with the existing Link component is the recommended approach. Lint rules, such as @next/next/no-html-link-for-pages, can aid in enforcing this consistency. If no such rule exists, a simple grep search for "a href=" within the repository should suffice to identify any discrepancies.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.