Skip to content

How can I make <Link> work with the new rewrites feature? #16014

Answered by ijjk
utkarshkukreti asked this question in Help
Discussion options

You must be logged in to vote

Hi, you can make this work by using mis-matching href and as values and manually providing the dynamic route params. We're aiming to streamline this so this is no longer needed, but the below example should allow you to achieve this on the latest version of Next.js

<Link href="/news/[slug]" as="/news/hello">
  <a>/blog/hello</a>
</Link>


<Link href="/news/[slug]?slug=hello" as="/blog/hello">
  <a>/blog/hello</a>
</Link>

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@linkurzweg
Comment options

@utkarshkukreti
Comment options

Answer selected by utkarshkukreti
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants