본문 바로가기
Next.js/Next.js

file system 기반 라우팅

by hihijh826 2024. 2. 14.
728x90
반응형
SMALL

📍파일기반 네비게이션 기능

- 리액트의 경우 react-router 라이브러리 사용

- next.js의 경우 페이지 개념을 기반으로 구축된 파일 시스템 기반 라우터 존재

=> 파일이 페이지(pages) 디렉토리에 추가되면 자동으로 경로로 사용 가능 

ex)

 

☑️사용법

☑️Link 함수를 이용한 페이지 이동

import Link from "next/link";

<li className= {homeStyles.listItem} key={id}>
            <Link href={`/post/${id}`}>
            <a>{title}</a>
            </Link>
728x90
반응형
LIST

'Next.js > Next.js' 카테고리의 다른 글

Client Component  (0) 2024.02.15
next 13 파일 구조  (0) 2024.02.15
type assetion(타입 표명)  (0) 2024.02.14
type annotation, type inference  (0) 2024.02.12
Typescript Type  (0) 2024.02.12