Rendering

use cache directive

Enable Cache Components before applying use cache to an eligible async function or component. Cache identity includes function identity and serialized inputs, including captured values. Read request APIs outside ordinary shared cached scopes; pass only safe, necessary arguments. Do not treat reusable output as an authorization decision. The sample is synthetic public data. Source: https://nextjs.org/docs/app/api-reference/directives/use-cache. Documentation-reviewed illustrative draft; installed declarations and runtime not verified.

Formal Syntax & Structure

nextjs syntaxnextjs
'use cache'

Working Example

Example Snippetnextjs
import { cacheLife } from 'next/cache';type Category = 'nature' | 'travel';export async function titles(category: Category) { 'use cache'; cacheLife('hours'); return category === 'nature' ? ['Fern Atlas'] : ['River Walk'];}
Next.js Reference