Next.js documentation mentions two ways to access the router
object: useRouter
for functional components and withRouter
for class-based components.
However, it does not mention something I came across a few times which is the Router
object accessed as follows, for example:
import Router from 'next/router'
Router.push("/")
Is it correct to use Router
in this way? Why doesn't Next.js documentation mention it?