Navigate From Code
Easy · Navigation
Sometimes you need to navigate from code instead of a link, for example after a button click or a form submit. In a Client Component, useRouter() from next/navigation gives you a router object, and router.push(url) moves to that page (adding it to the browser history).
When the Go to dashboard button is clicked, navigate to /dashboard.
Note: in the App Router, useRouter comes from next/navigation, not from next/router (that one is for the old Pages Router).
Next: Image Optimizer URL