Next.js application은 기본적으로(by default) React Server Components를 사용한다. 서버 컴포넌트를 사용해 데이터를 fetch하는 것은 상대적으로 새로운 접근이며, 여기엔 몇가지 이점이 있다:
- Server Components supports promises, providing a simpler solution for asynchronous tasks like data fetching. You can use async/await syntax without reaching out for
useEffect, useState or data fetching libraries(e.g. SWR, TanStack-query).
- 즉 기존 React의 client-side data fetching에 비해 컴포넌트의 코드가 간결해지는 것으로 보인다. fetching 자체에는
useState, useEffect등이 필요 없어지는 것이기 때문에.
- Server Components execute on the server, so you can keep expensive data fetches and logic on the server and only send the result to the client.
- As mentioned before, since Server Components execute on the server, you can query the database directly without an additional API layer.
⇒ 하이라이트한 부분은 API 서버가 따로 있을때도 해당되는 장점. 마지막 부분은 풀스택일때? 장점으로 볼 수 있을듯. API 서버를 따로 개발하는 경우라면 이부분을 신경쓸 이유는 없으니까.