Data fetching is a core feature of Next.js that allows you to load data from APIs, databases, or external services efficiently. Next.js provides different data-fetching methods depending on where and how the data is needed.
In the App Router (app/ directory), data fetching is handled primarily using the fetch() API.
By default, data is fetched on the server, making applications faster and SEO-friendly.
Runs on the server
Data is not exposed to the browser
Ideal for SEO and secure data
By default, fetch() uses static rendering.
Data is fetched at build time
Best for blogs, landing pages, and static content
Very fast performance
To fetch fresh data on every request, use:
Data is fetched on each request
Suitable for dashboards and real-time data
You can revalidate data after a specific time.
Data refreshes every 60 seconds
Combines speed and freshness
For interactive or user-driven data, fetch data on the client.
| Use Case | Method |
|---|---|
| SEO content | Server-side fetch |
| Static pages | Build-time fetch |
| Real-time data | Dynamic fetch |
| User interaction | Client-side fetch |
Next.js data fetching is flexible and optimized by default. By choosing the right fetching strategy—static, dynamic, or client-side—you can build fast, scalable, and SEO-friendly applications.
Take quizzes related to this topic and see where you stand!
Start Quiz Now