Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to redirect programatically in nextjs

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

PREVIOUS NEXT
Code Example
Javascript :: prevent form submit javascript 
Javascript :: disable yellow box react native 
Javascript :: npm ERR! code EACCES 
Javascript :: on click fade out jquery 
Javascript :: document on click dynamic element 
Javascript :: npm ERR! path node_modules/node-sass 
Javascript :: hello world jquery 
Javascript :: string to url javascript 
Javascript :: how to find prime numbers in an array in javascript 
Javascript :: js wait for time 
Javascript :: react native status bar color 
Javascript :: base64 decode javascript 
Javascript :: jquery ajax get 
Javascript :: username validation in javascript 
Javascript :: js get timezone name 
Javascript :: js yesterday date 
Javascript :: show and hide div tag based on checkbox selection using jquery 
Javascript :: set up node js server express 
Javascript :: last query prisma 
Javascript :: jquery each has class 
Javascript :: javasctipt unix timestamp from date 
Javascript :: jquery insert element as first child 
Javascript :: hide button using javascript 
Javascript :: jquery get origin url 
Javascript :: react native settimeout 
Javascript :: discord.js custom create channel 
Javascript :: chartjs start at 0 
Javascript :: generate random boolean javascript 
Javascript :: javascript get first 10 characters of string 
Javascript :: jquery check if audio is playing 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =