Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

next js navigation to other page in a function

import { useRouter } from 'next/router'

function Home() {
  const router = useRouter()


  const handleClick = e => {
    e.preventDefault()
    router.push('/some-path')
  }

  return (
    <button type="button" onClick={handleClick}>
      Go Somewhere
    </button>
  )
}

Comment

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>
)}
Comment

PREVIOUS NEXT
Code Example
Javascript :: first letter capital in javascript 
Javascript :: javascript compare object arrays keep only entries not in both 
Javascript :: insertbefore jquery 
Javascript :: pass an array to javascript in asp net core list 
Javascript :: how to validate age above 18 in javascript 
Javascript :: install bun.sh 
Javascript :: remove first char javascript 
Javascript :: execute JS code after pressing space bar 
Javascript :: set stroke color canvas 
Javascript :: javascript click event notifications 
Javascript :: asignar val select2 js 
Javascript :: javascript context color 
Javascript :: js check if date is future 
Javascript :: react native text input number only 
Javascript :: How to add and play sounds in JS 
Javascript :: jest ReferenceError: TextEncoder is not defined 
Javascript :: number validation in javascript 
Javascript :: js Convert the characters to the html 
Javascript :: url decode in javascript 
Javascript :: aos js cdn 
Javascript :: input radio checked jquery 
Javascript :: changing the active class on press 
Javascript :: if media queries jquery 
Javascript :: js selection box excel node 
Javascript :: call function in javascript from html 
Javascript :: how to detect account change in metamask 
Javascript :: javascript multiline string 
Javascript :: compare NaN in javascript if condititon 
Javascript :: check if file is empty javascript fs 
Javascript :: mongo query by object id node js 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =