mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
- Fetch logging configuration is no longer experimental - Add `unstable_noStore` reference - Add `unstable_cache` reference - Add codemod docs for `next/og` import changes - Update docs around stable Server Actions - Add example of revalidating the entire data cache - Update static export docs for `next export` command removal - Update minimum required Node.js version - Add `viewport` and `generateViewport` reference Co-authored-by: Balázs Orbán <[email protected]> Co-authored-by: Delba de Oliveira <[email protected]>
44 lines
1.4 KiB
Plaintext
44 lines
1.4 KiB
Plaintext
---
|
|
title: unstable_noStore
|
|
description: API Reference for the unstable_noStore function.
|
|
---
|
|
|
|
`unstable_noStore` can be used to declaratively opt out of static rendering and indicate a particular component should not be cached.
|
|
|
|
```jsx
|
|
import { unstable_noStore as noStore } from 'next/cache';
|
|
|
|
export default async function Component() {
|
|
noStore();
|
|
const result = await db.query(...);
|
|
...
|
|
}
|
|
```
|
|
|
|
> **Good to know**:
|
|
>
|
|
> - `unstable_noStore` is equivalent to `cache: 'no-store'` on a `fetch`
|
|
> - `unstable_noStore` is preferred over `export const dynamic = 'force-dynamic'` as it is more granular and can be used on a per-component basis
|
|
|
|
- Using `unstable_noStore` inside [`unstable_cache`](/docs/app/api-reference/functions/unstable_cache) will not opt out of static generation. Instead, it will defer to the cache configuration to determine whether to cache the result or not.
|
|
|
|
## Usage
|
|
|
|
If you prefer not to pass additional options to `fetch`, like `cache: 'no-store'` or `next: { revalidate: 0 }`, you can use `noStore()` as a replacement for all of these use cases.
|
|
|
|
```jsx
|
|
import { unstable_noStore as noStore } from 'next/cache';
|
|
|
|
export default async function Component() {
|
|
noStore();
|
|
const result = await db.query(...);
|
|
...
|
|
}
|
|
```
|
|
|
|
## Version History
|
|
|
|
| Version | Changes |
|
|
| --------- | ------------------------------ |
|
|
| `v14.0.0` | `unstable_noStore` introduced. |
|