question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Link should support relative href in dynamic routes

See original GitHub issue

Feature 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:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Timercommented, Sep 14, 2020
0reactions
balazsorban44commented, Jan 29, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found