Put in order · Next.js course · Module 2: Routing and Layouts

Importing and Using useRouter

Arrange the import and usage syntax of the useRouter hook

Items to put in order

  • = useRouter()
  • const router
  • import { useRouter }
  • from 'next/navigation'
Show the answer

Correct order:

  1. import { useRouter }
  2. from 'next/navigation'
  3. const router
  4. = useRouter()