const router = useRouter();
기존 react의 usenavigate 역할이다
<div
onClick={() => {
router.push("/");
}}
className="w-[33%] flex justify-center text-4xl font-bold cursor-pointer text-teal-500">
중고홈짐
</div>
클릭이벤트 통해서 router.push(url)로 이동
<Link href="/" className="logo">로고</Link>
import Link, { useRouter } from "next/navigation";
link 또한 react와 같이 쓸 수 있음 대신 next/navigation에서 호출해야 하고 to가 아닌 href속성을 갖는다.
'프로그래밍 > NextJS' 카테고리의 다른 글
nextjs nodemailer 연동하기 (0) | 2024.01.08 |
---|---|
nextjs api폴더 리팩토링 (0) | 2024.01.06 |
nextjs에서 prsima, planetScale 연결 (1) | 2024.01.04 |
nextjs aws를 이용한 이미지 업로드 (0) | 2023.12.14 |
nextjs 소셜로그인 구현 (0) | 2023.12.11 |