📋 app과 document Next.js 프로젝트를 생성하면 볼 수 있는 두 가지 중요한 페이지가 있다. 바로 app과 document이다. 이 두 기본 페이지의 역할은 무엇이고 왜 사용하는지에 대해서도 알아보자. 📌 1. _app _app은 서버로 요청이 들어왔을 때 가장 먼저 실행되는 컴포넌트이며, 페이지에 적용할 공통 레이아웃의 역할을 한다. React의 Router.tsx (App.tsx) 컴포넌트와 유사하다고 볼 수 있다. >Next.js uses the App component to initialize pages. You can override it and control the page initialization and: Persist layouts between page changes Keeping state when navigating pages Inject additional data into p
📋 getStaticProps vs getServerSideProps getStaticProps와 getServerSideProps는 모두 사전 렌더링이 필요할 때 사용하는 Next.js 내장 기능이다. 그렇다면 이 둘이 정확히 무엇인지, 또 어떤 차이가 있는지 알아보자. 📌 1. getStaticProps > If you export a function called getStaticProps (Static Site Generation) from a page, Next.js will pre-render this page at build time using the props returned by getStaticProps. -Next.js 공식 문서 getStaticProps는 빌드할 때 딱 한 번만 실행되는 정적 사이트 생성(Static Site Generation) 함수이다. 다시 빌드를 하지 않는다면