Reputation: 11
I have a Next.js page /product
When I'm on /product
, and I click product
on the top banner(navbar) (to /product), I wanna get refresh page in /product
page.
how to refresh in the same page ?
For example, in my top navbar I have three different link router
when i'm in product
page and click product link again
but i want to refresh whole page again.
i have tried this code down below was not solution for me
<a onClick={()=>router.push('/product')} >product</a>
Upvotes: 1
Views: 3142
Reputation: 53
You can use router.reload() function like this:
import { useRouter } from 'next/router'
export default function Page() {
const router = useRouter()
return (
<button type="button" onClick={() => router.reload()}>
Click here to reload
</button>
)
}
Upvotes: 2
Reputation: 376
you can use javascript function-
window.href.reload()
this will reload the page. If you're using nextjs/reactjs you can use it with some promises and conditions.. Hope you'll get your answer. If you still facing issue, just lemme know, i will help you. Thanks
Upvotes: 0