Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@ impl ReactServerComponentValidator {
"unstable_cacheLife",
"cacheTag",
"unstable_cacheTag",
"unstable_navigation",
// "unstable_noStore" // no-op in client, but allowed for legacy reasons
],
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2743,7 +2743,7 @@ impl<C: Comments> VisitMut for ServerActions<C> {
ServerActionsMode::Turbopack => {
new.push(ModuleItem::Stmt(Stmt::Expr(ExprStmt {
expr: Box::new(Expr::Lit(Lit::Str(
atom!("use turbopack no side effects").into(),
atom!("use turbopack: no side effects").into(),
))),
span: DUMMY_SP,
})));
Expand All @@ -2752,7 +2752,7 @@ impl<C: Comments> VisitMut for ServerActions<C> {
let mut module_items = vec![
ModuleItem::Stmt(Stmt::Expr(ExprStmt {
expr: Box::new(Expr::Lit(Lit::Str(
atom!("use turbopack no side effects").into(),
atom!("use turbopack: no side effects").into(),
))),
span: DUMMY_SP,
})),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { unstable_navigation } from 'next/cache'

export async function test() {
await unstable_navigation()
return null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { unstable_navigation } from 'next/cache';
export async function test() {
await unstable_navigation();
return null;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
x You're importing a module that depends on "unstable_navigation" into a React Client Component module. This API is only available in Server Components but one of its parents is marked with "use
| client", so this module is also a Client Component.
| Learn more: https://nextjs.org/docs/app/building-your-application/rendering
|
|
,-[input.js:1:1]
1 | import { unstable_navigation } from 'next/cache'
: ^^^^^^^^^^^^^^^^^^^
`----
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { unstable_navigation } from 'next/cache'

export async function test() {
await unstable_navigation()
return null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { unstable_navigation } from 'next/cache';
export async function test() {
await unstable_navigation();
return null;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
x You're importing a module that depends on "unstable_navigation". This API is only available in Server Components in the App Router, but you are using it in the Pages Router.
| Learn more: https://nextjs.org/docs/app/building-your-application/rendering/server-components
|
|
,-[input.js:1:1]
1 | import { unstable_navigation } from 'next/cache'
: ^^^^^^^^^^^^^^^^^^^
`----

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/01-app/01-getting-started/08-caching.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ A cache directive gives a result a lifetime, information Next.js uses to apply r

> **Good to know:** We recommend pairing every cache directive with a [`cacheLife`](/docs/app/api-reference/functions/cacheLife). Without one, the implicit `default` profile applies.

Arguments and any closed-over values from parent scopes automatically become part of the [cache key](/docs/app/api-reference/directives/use-cache#cache-keys), which means different inputs will produce separate cache entries. See [serialization requirements and constraints](/docs/app/api-reference/directives/use-cache#constraints) for details on what can be cached and how arguments work.
Arguments and any values captured from parent scopes automatically become part of the [cache key](/docs/app/api-reference/directives/use-cache#cache-keys), which means different inputs will produce separate cache entries. See [cache output](/docs/app/api-reference/directives/use-cache#cache-output) for what an entry holds, and [serialization requirements and constraints](/docs/app/api-reference/directives/use-cache#constraints) for details on what can be cached and how arguments work.

### Data-level caching

Expand Down
2 changes: 1 addition & 1 deletion docs/01-app/03-api-reference/01-directives/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ A directive imposes rules on the code it covers:
- **`'use server'`** marks the functions it covers as [Server Functions](/docs/app/glossary#server-function). Server Functions must be `async`. When invoked from a Client Component, their arguments and return values are serialized across the network. The Client Component receives a reference that invokes the function on the server, not the function's code.
- **`'use cache'`** caches the output of the functions or components it covers based on their inputs. Cached functions and components must be `async`. Their arguments and return values must be serializable, except for non-serializable values that the cached code passes through without inspecting. Cached code cannot read request-time APIs like `cookies()`, `headers()`, or `searchParams` directly.

File-level directive rules also apply to framework exports. With `'use cache'` at the top of a page or layout file, exported functions such as `generateMetadata` and `generateStaticParams` must be `async`. A file-level `'use cache'` directive does not allow non-function exports.
With `'use cache'` at the top of a page or layout file, exported functions such as `generateMetadata` and `generateStaticParams` must be `async`.

## Placement decides what you cache

Expand Down
Loading
Loading