Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

navigate to another page in next js when click

import { useRouter } from 'next/router';
const NavComponent = ({navItems,logo})=> {
const router = useRouter()
return (
     <div onClick={() => {
            router.push('/');
          }}
          className="h-auto transition cursor-pointer hover:scale-105"
        >
          <h4 className="text-2xl text-white uppercase font-neuro hover:text-secondary text-shadow">Straw Hats</h4>
        </div>
)}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #navigate #page #js #click
ADD COMMENT
Topic
Name
8+4 =