문서
App Router 사용하기
unstableNoStore

unstable_noStore

unstable_noStore는 정적 렌더링을 선택적으로 제외하고 특정 컴포넌트를 캐시하지 않아야 함을 선언적으로 나타내는 데 사용할 수 있습니다.

import { unstable_noStore as noStore } from 'next/cache';
 
export default async function Component() {
  noStore();
  const result = await db.query(...);
  // ...
}

알아두면 좋은 점:

  • unstable_noStorefetch에서 cache: 'no-store'와 동등합니다
  • unstable_noStoreexport const dynamic = 'force-dynamic'보다 더 세분화되어 컴포넌트 단위로 사용할 수 있으므로 선호됩니다
  • unstable_cache 내에서 unstable_noStore를 사용하면 정적 생성에서 제외되지 않습니다. 대신, 결과를 캐시할지 여부를 결정하기 위해 캐시 구성을 참조합니다.

사용법

fetchcache: 'no-store' 또는 next: { revalidate: 0 }와 같은 추가 옵션을 전달하지 않기를 선호한다면, 이러한 모든 사용 사례에 대한 대체로 noStore()를 사용할 수 있습니다.

import { unstable_noStore as noStore } from 'next/cache';
 
export default async function Component() {
  noStore();
  const result = await db.query(...);
  // ...
}

버전 기록

버전변경 사항
v14.0.0unstable_noStore 도입됨.