Skip to content

Should NavItem use <A> (router link) rather than <a> (HTML anchor)? #423

Description

@lizidev

Discussed in #416

Originally posted by LeoniePhiline June 7, 2025
Hi!

we‘ve had a bug with NavItem seeming to work unreliably. As it turned out, we had the incorrect expectation that a link-NavItem would act like a Leptos router link <A>. However, NavItem in fact renders as HTML anchor <a>.

One of the behavior differences comes up when using nested <Routes>:

The Leptos router link component resolves the href relative to the parent route, while with the HTML anchor element, the browser uses the existing URL and has no knowledge about routes. This causes different resulting target navigation URLs depending on if the current url does or does not have a trailing slash.

This observation made me consider that maybe NavItem should use <A> in thaw 0.5.

What do you think? Is there any advantage at all in the use of the html anchor element rather than the routes-aware Leptos router component?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions