Link should support relative href in dynamic routes
See original GitHub issueFeature request
The problem is that for Links inside a particular dynamic route like “/site/[slug]/comments” you have to always use the
additional as
prop and somehow grab the slug
variable.
Describe the solution you’d like
It should be possible to use relative hrefs inside dynamic routes. For example we are on some page /site/123
And we want to provide a Link to the comments /site/123/comments
. Instead of writing
<Link href="/site/[slug]/comments" as={`/site/${slug}/comments`}>
<a>Comments</a>
</Link>
We should be able to tell the router, that comments
is a relative path of the current page. For example:
<Link href="./comments">
<a>Comments</a>
</Link>
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Does react-router support relative links? - Stack Overflow
in react-router v4 relative paths are supported. The history library resolves relative paths 'just like a browser would' so that a <Link to="two"...
Read more >RFC: Next.js <Link to=""> to handle dynamic routes #8207
This proposal uses to instead of making href have different behavior so we could potentially make it opt-into not using the child component, ......
Read more >React Router - Relative Links Example | Jason Watmore's Blog
This is a quick example of how to navigate up levels with relative links using the React Router Link component.
Read more >React Router Tutorial - 13 - Relative Links - YouTube
Courses - https://learn.codevolution.dev/ Support UPI - https:// support.codevolution.dev/ Support PayPal ...
Read more >next/link | Next.js
If the route has dynamic segments There is nothing to do when linking to a dynamic route, including catch all routes, since Next.js...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://github.com/vercel/next.js/pull/16634
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.