Caching with the use cache directive
Answer: The use cache directive caches the return value of async functions and components when Cache Components are enabled.
Enable Cache Components
use cache is a Cache Components feature. Enable it with the cacheComponents option in next.config.
Placement
Add use cache at function, component, or file level. Cached functions and components must be async. At file level, every exported function becomes a cached function and must also be async.
Data functions
To cache an asynchronous function that fetches data, add the use cache directive near the top of that function.
See also
Claims
- id: C1 claim: use cache caches async return values. source: S1 evidence: "The
use cachedirective caches the return value of async functions and components."
- id: C2 claim: use cache needs Cache Components. source: S2 evidence: "
use cacheis a Cache Components feature."
- id: C3 claim: File-level cached exports must be async. source: S2 evidence: "When used at file level, every exported function becomes a cached function and must also"
- id: C4 claim: Cache a data function with use cache. source: S1 evidence: "To cache an asynchronous function that fetches data, add the
use cachedirective at the"
Sources
- [S1] Caching. Next.js docs. https://nextjs.org/docs/app/getting-started/caching . License: MIT (vercel/next.js). Accessed 2026-11-09.
- [S2] use cache. Next.js docs. https://nextjs.org/docs/app/api-reference/directives/use-cache . License: MIT (vercel/next.js). Accessed 2026-11-09.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Copyright (c) 2025 Vercel, Inc. Sources: Next.js docs (vercel/next.js on GitHub / nextjs.org), MIT (https://raw.githubusercontent.com/vercel/next.js/canary/license.md). Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Next.js docs, Caching, MIT (vercel/next.js); Next.js docs, use cache, MIT (vercel/next.js). Copyright (c) 2025 Vercel, Inc. MIT (https://raw.githubusercontent.com/vercel/next.js/canary/license.md).
Cite this
iinventedlight. 2026. "Caching with the use cache directive." iinventedlight Library, iil:note:n2v44mbc, version of 2026-11-09. https://iinventedlight.com/library/notes/nextjs-caching-use-cache/. License: CC-BY-4.0.
@misc{iil_note_n2v44mbc,
author = {{iinventedlight}},
title = {{Caching with the use cache directive}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-09},
url = {https://iinventedlight.com/library/notes/nextjs-caching-use-cache/},
note = {Permanent ID iil:note:n2v44mbc. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/nextjs-caching-use-cache.md.