next.js shallow routing

lynn·2022년 6월 7일
0

Front-End

목록 보기
17/24

Shallow routing

새로고침 하지 않고(=data fetching 메소드를 다시 실행하지 않고) url을 불러올 수 있는 기능. 이때 업데이트된 pathname과 query를 받아오게 된다.

(data fetching method: getServerSideProps, getStaticProps, getInitialProps, ...)

기존 라우팅 방식인 router.push에서 option을 shallow로 입력하면 됨

router.push(url,as,{shallow:true})

url: 이동하고자 하는 주소
as: 브라우저 url 바에 표시되는 주소(옵션)

profile
개발 공부한 걸 올립니다

0개의 댓글