Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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>
  )
}

Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #js #navigation #page #function
ADD COMMENT
Topic
Name
8+6 =