Functions
unstable_cache: Migration reference
Legacy persistent data-cache wrapper, superseded by use cache in Next.js 16. The function representation and arguments contribute to the key; add keyParts for relevant closed-over values not passed as arguments. Tags are invalidation labels rather than identity. Avoid reading cookies or headers inside the callback, and do not cache private data under a shared key. Source: https://nextjs.org/docs/app/api-reference/functions/unstable_cache. Documentation-reviewed illustrative draft; installed declarations and runtime not verified.
Formal Syntax & Structure
nextjs syntaxnextjs
unstable_cache(fetchData, keyParts?, options?)Working Example
Example Snippetnextjs
import { unstable_cache } from 'next/cache';const getTitle = unstable_cache(async (slug: string) => slug === 'moss' ? 'Moss Garden' : null, ['public-title'], { revalidate: 60 });