Data Fetching Overview
Next.js extends the native fetch API with caching and revalidation.
Official docs
Server-Side Fetching
In Server Components, fetch directly:
async function getData() {
const res = await fetch('https://api.example.com/data', {
next: { revalidate: 3600 },
});
return res.json();
}
Caching Strategies
| Option | Behavior |
|---|---|
| Default | Cached indefinitely |
{ cache: 'no-store' } | Always fresh |
{ next: { revalidate: N } } | Revalidate every N seconds |