Kindaa confuse in usage of both and i am using both of them in redirecting. 😬
For further actions, you may consider blocking this person and/or reporting abuse
Kindaa confuse in usage of both and i am using both of them in redirecting. 😬
For further actions, you may consider blocking this person and/or reporting abuse
Bruno Barbosa -
alakkadshaw -
alakkadshaw -
Brian -
Once suspended, rishabh0906 will not be able to comment or publish posts until their suspension is removed.
Once unsuspended, rishabh0906 will be able to comment and publish posts again.
Once unpublished, all posts by rishabh0906 will become hidden and only accessible to themselves.
If rishabh0906 is not suspended, they can still re-publish their posts from their dashboard.
Once unpublished, this post will become invisible to the public and only accessible to Rishabh Jain.
They can still re-publish the post if they are not suspended.
Thanks for keeping DEV Community safe. Here is what you can do to flag rishabh0906:
Unflagging rishabh0906 will restore default visibility to their posts.
Top comments (2)
Hi @rishabh0906, I'll try to answer your question, but before that, let me say some useful information.
<Link>tags are the best option if they can be used, as they have a bunch of nice features like prefetching the page when the link is in the viewport.As per your question,
<Link>tags have to be used every time you would put a link on a page (e.g. with an<a>tag), whilerouter.push()have to be used whenever a<Link>tag can't, for example, if you have to redirect the user after some complex logic.Example
An example of link usage:
An example of
useRouterusage:Caveats
The
<Link>tag has to be used only for internal navigation. if you have to redirect the user to an external page, simply use an<a>tag.I guess the easy answer is
Use
<Link href="" passHref>when you can define the destination in JSX.And use
useRouterwhen you want to programmatically redirect using javascript.eg. instead of using
window.location = ""userouter.push("")