Answers for "link nextjs"

35

next js link

import Link from "next/link";   //import this
     
<Link href="/">    //wrap a tag with Link
     <a>Home</a>
</Link>

<Link href="https://nextjs.org">   //external page
      <a>Next.js</a>
 </Link>
Posted by: Guest on June-25-2021
3

router nextjs

import { useRouter } from 'next/router'

function ActiveLink({ children, href }) {
  const router = useRouter()

  const handleClick = (e) => {
    e.preventDefault()
    router.push(href)
  }

  return (
    <a href={href} onClick={handleClick} style={style}>
      {children}
    </a>
  )
}

export default ActiveLink
Posted by: Guest on November-16-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language