Implements data fetching in Next.js (Server Components, fetch, cache, revalidate). Use when the user asks to load data for a page, implement SSR, set up caching, or fix loading/streaming behavior.
page.tsx veya layout.tsx içinde async fonksiyon; await fetch() veya lib fonksiyonu.fetch varsayılan olarak cache’ler; cache: 'no-store' veya next: { revalidate: 60 } ile davranışı ayarla.export default async function Page() {
const res = await fetch('https://api.example.com/posts', {
next: { revalidate: 60 },
});
const posts = await res.json();
return <PostList posts={posts} />;
}
loading.tsx (Suspense) ekle.error.tsx ile sınır belirle; gerekirse error.tsx içinde tekrar fetch yapma, sadece UI ve reset.useEffect + fetch (client component).revalidate: 60 (saniye) ile periyodik yenileme.cache: 'no-store' veya dynamic = 'force-dynamic'.export const revalidate = 60 sayfa/layout’ta.loading.tsx / error.tsx gerekirse eklendi