Ch 4 · Getting Data Onto the Page · Next.js
Topic 4 of 7 in Next.js — Build the App You Deploy — 4 lessons.
fetch in a Server Component
Compare that with the React pattern you may have met: state, an effect, a loading flag, an error flag, four re-renders. Here the data is fetched before the HTML exists, so the user never sees an empty state at all.
Caching, and the Setting That Bites
By default Next.js may cache a fetch result and reuse it. That is excellent for a list of products that changes weekly, and completely wrong for an order list that must be current.
Handling the Empty Case
A brand-new client opens your app and sees nothing. Whether that blank space says "No orders yet. Create your first one." or simply shows an empty box is most of the difference between software that feels finished and software that feels broken.