next link params

Solutions on MaxInterview for next link params by the best coders in the world

showing results for - "next link params"
Beatrice
08 Sep 2020
1------------- index.js ---------------
2import Link from "next/link"
3
4export default function IndexPage() {
5  return (
6    <Link
7      href={{
8        pathname: "/about",
9        query: { id: "test" },
10      }}
11    >
12      <a>About page</a>
13    </Link>
14  )
15}
16
17------------- about.js ---------------
18
19import { useRouter } from "next/router"
20
21export default function AboutPage() {
22  const router = useRouter()
23  const {
24    query: { id },
25  } = router
26  return <div>About us: {id}</div>
27}