배경 지식 자료:
출처 및 참고 자료:
https://nextjs.org/docs/app/building-your-application/rendering/server-components#streaming
https://nextjs.org/docs/app/building-your-application/rendering/client-components
Using Next.js for a React app that relies solely on CSR
Next.js의 렌더링은 App router 기준으로 크게 Server Component와 Client Component 두가지 경우로 나눌 수 있다.
Next.js(app router)는 by default로 server component를 사용한다. 즉 Next.js 프로젝트에서 일반적으로 리액트 컴포넌트를 만들면 그게 server component로 취급된다는 것이다. Next.js server component는 React Server Components(RSC)를 기반으로 한다. Server Component를 사용할때의 렌더링은 다시 세가지 렌더링 전략으로 나눌 수 있다. ⇒ Static Rendering, Dynamic Rendering, Streaming
route 접속 (request) 시마다 새로 렌더링 된다. (routes are rendered for each user at request time)
static rendering과는 반대로, dynamic rendering is useful when a route has data that is personalized to the user or has information that can only be known at request time, such as cookies or the URL's search params.
caching?
<aside> 💡 Dynamic Routes with Cached Data
In most websites, routes are not fully static or fully dynamic - it's a spectrum. For example, you can have an e-commerce page that uses cached product data that's revalidated at an interval, but also has uncached, personalized customer data.
In Next.js, you can have dynamically rendered routes that have both cached and uncached data. This is because the RSC Payload and data are cached separately. This allows you to opt into dynamic rendering without worrying about the performance impact of fetching all the data at request time.
Learn more about the full-route cache and Data Cache.
</aside>
기존의 getServerSideProps(SSR)에 해당한다고 볼 수 있다.
dynamic rendering을 사용하는 방법
렌더링 중에, *dynamic function이나 uncached data request를 하는 것이 발견되면, Next.js는 자동으로 Dynamic Rendering을 적용한다고 한다. (Next.js will switch to dynamically rendering the whole route)
cookies(), headers(), searchParams props on a Page, etc.) ⇒ using any of these functions will opt the whole route into dynamic rendering at request time.아래 표는 dynamic function과 caching이 어떻게 static 또는 dynamic rendering을 결정하는지 보여준다.

아무튼 중요한 것은, Next.js를 사용할때는 개발자로서 우리가 직접 static / dynamic rendering을 결정하는 개념이 아니라는 것이다. Next.js가 자동으로 우리가 어떤 기능이나 API를 사용했는지에 따라 알아서 결정한다. 따라서 어떤 기능을 사용할때 렌더링까지 미리 생각할 수 있어야 한다고 볼 수도 있을 것이다.
