mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
This PR introduces a new API, `unstable_noStore`, which will allow users to declaratively opt out of caching anywhere during static generation in the same way that you can specify `cache: 'no-store'` on a fetch call in Next.js.
An important caveat and difference from just calling `cookies()` to opt-out of static generation is that this won't opt you out when called from within `unstable_cache` and instead defers to the cache configuration to it.
```
import {unstable_noStore as noStore} from 'next/cache';
export default async function Component() {
noStore();
const result = await db.query(...);
}
```
13 lines
292 B
TypeScript
13 lines
292 B
TypeScript
import { getUncachedRandomData } from '../no-store-fn'
|
|
|
|
export default async function Page() {
|
|
const uncachedData = await getUncachedRandomData()
|
|
|
|
return (
|
|
<div>
|
|
<p>random: {Math.random()}</p>
|
|
<p id="uncached-data">uncachedData: {uncachedData.random}</p>
|
|
</div>
|
|
)
|
|
}
|