rsnext/docs/routing/imperatively.md
Lee Robinson 7f99895076
Update imperative routing docs to have better a11y (#29382)
We should recommend using a `button` instead of a `span` 👍
2021-09-27 02:04:58 +00:00

941 B

description
Client-side navigations are also possible using the Next.js Router instead of the Link component. Learn more here.

Imperatively

Examples

next/link should be able to cover most of your routing needs, but you can also do client-side navigations without it, take a look at the documentation for next/router.

The following example shows how to do basic page navigations with useRouter:

import { useRouter } from 'next/router'

export default function ReadMore() {
  const router = useRouter()

  return (
    <button onClick={() => router.push('/about')}>
      Click here to read more
    </button>
  )
}