fetch 缓存与增量静态再生成
在组件中直接使用 fetch
- 服务端组件中直接 await fetch,默认走服务端。
- 客户端组件中应通过 API 或 Server Actions 间接获取。
export default async function Page() {
const res = await fetch("https://api.example.com/data");
const data = await res.json();
return <pre>{JSON.stringify(data, null, 2)}</pre>;
}