Answers for "next link params"

1

next link params

------------- index.js ---------------
import Link from "next/link"

export default function IndexPage() {
  return (
    <Link
      href={{
        pathname: "/about",
        query: { id: "test" },
      }}
    >
      <a>About page</a>
    </Link>
  )
}

------------- about.js ---------------

import { useRouter } from "next/router"

export default function AboutPage() {
  const router = useRouter()
  const {
    query: { id },
  } = router
  return <div>About us: {id}</div>
}
Posted by: Guest on August-25-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language