This post is based on Next.js 15. Some details may change in later versions.
Next.js App Router combines modern React features with a server-centered approach to data fetching.
This can help build faster and more efficient web applications.
This series explores the feature from basic concepts to advanced usage.
Part 1 covers:
Next.js App Router operates on React Server Components (SSR).
Server components can use server-only capabilities unavailable in the browser, including data fetching.
Next.js generally recommends
fetching data on the server
.
Doing so prepares the HTML before sending it to the client, which benefits loading speed and SEO.
: Used when data must be retrieved dynamically after user interaction.
Route handlers (API routes)
: Act as backend APIs and communicate with external systems.
Because App Router uses folder-based routing, data is fetched inside component files in the app/ directory.
The function most commonly used to retrieve data in Next.js is fetch.
It is almost the same as the browser's native fetch, but Next.js gives it special behavior.
For example, the following code retrieves posts from JSONPlaceholder.
The code runs in a server component and fetches data before rendering HTML.
Compared with fetching data on the client and showing a loading state, this can provide a faster and more stable user experience.
We have learned how data fetching works in Next.js, where it can happen, and the basics of fetch.
Prerendering data through server components offers benefits for both performance and SEO.
The next part explores advanced fetch options, caching behavior, and ISR.