use cache
directive to the top of the function definition.1async function getData() {2'use cache';3// ...4}56async function ProductList() {7const products = await getData();8// ...9}1011export default async function Page() {12return <ProductList />;13}
use cache
.layout.tsx
, page.tsx
and <ProductList>
aren't explicitly annotated with use cache
, but Next.js infers they're static because they do not use any Dynamic APIs. If they started to, Next.js will guide the developer to either add use cache
or a <Suspense>
boundary.use cache
directive and describes caching behavior once stable.