Difference in the navigation (React Router v6)

The difference is between relative and absolute navigation. "/page2" with a leading slash "/" is an absolute path where "page2" is a relative path. If there was a nested route from the current location "page2" would navigate relative to the current location.

Relative Routes and Links

If you are navigating from “page1” to “page2” these should like they are at the same “relative” level, so you’d probably want to use absolute linking "/page2" or a relative path to a sibling path "../page2".

Link

Leave a Comment