How jump to another page anchor target from current page in next.js 14

67 views Asked by At

I am building a website with Next.js 14, and use anchor tag scrolling the target in Homepage. but I still have a Blog page, the problem is, when the current page is blog page or post page, how to jump to the anchor tag in the homepage, i try to use useRouter and click envent, but stille not working,

onClick={() => router.push("http://localhost:3000/#about")

when i click the link in /blog or /blog/** page, it jump to homepage, but not target to the anchor tag. How do i solve this problem, and scrolling to the anchor tag.

better jump to homepage and scrolling to the target anchor.

0

There are 0 answers