0

I'm new nextJs & I need help creating an URL for redirecting to a detail page that includes a id as part of the URL after an onclick event is triggered, below is my code

Import {Router} from 'next'
const router = Router
const redirect =(id)=>{
    const url = `/hello/${id}/world`
    router.push(url)
}


render(
  <button onClick={(element)=>. 
     {redirect(element.id)}}></button>

)

I've created the page with the exact name hello-world and I'm expecting that when the button is clicked, the user should be redirected to a hello/id/world page, but instead a 404 page not found error is returned

Drew Reese
  • 165,259
  • 14
  • 153
  • 181
Tosin Ayoola
  • 77
  • 1
  • 9

0 Answers0