I have a <Link>
to a certain page on my Next.js website. Upon clicking it, I want the webpage to hard reload after it redirects to the destination page (whether it reloads before or after the redirect is not important). I have tried using router.push
as well but a hard refresh does not occur. Any help would be appreciated.
Asked
Active
Viewed 1.5k times
6

Niranjan Rajesh
- 85
- 1
- 1
- 4
2 Answers
8
If you want to refresh the page on load use simple anchor tags, if you want more control over reloading the page, Refer this: https://nextjs.org/docs/api-reference/next/router#routerreload

Siddharth Varangaonkar
- 391
- 2
- 7
4
Another solution to do hard reload on navigation/redirect in next.js is to use native browser location API, like this
function onClick() {
window.location.href = "/destination"
}
<Link onClick={onClick}>link</Link>

artplan
- 41
- 1