Skip to content

Commit c2863c8

Browse files
icyJosephmolebox
andauthored
Docs/sync with new features 0 (#84861)
Sync w/ isolatedDevBuild and updateTag+revalidatePath/Tag --------- Co-authored-by: Rich Haines <[email protected]>
1 parent 0562751 commit c2863c8

File tree

5 files changed

+82
-33
lines changed

5 files changed

+82
-33
lines changed

docs/01-app/02-guides/local-development.mdx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ module.exports = {
200200

201201
[Learn more about fetch logging](/docs/app/api-reference/config/next-config-js/logging).
202202

203-
## Turbopack tracing
203+
### Turbopack tracing
204204

205205
Turbopack tracing is a tool that helps you understand the performance of your application during local development.
206206
It provides detailed information about the time taken for each module to compile and how they are related.
@@ -214,22 +214,24 @@ It provides detailed information about the time taken for each module to compile
214214

215215
1. Navigate around your application or make edits to files to reproduce the problem.
216216
1. Stop the Next.js development server.
217-
1. A file called `trace-turbopack` will be available in the `.next` folder.
217+
1. A file called `trace-turbopack` will be available in the `.next/dev` folder.
218218
1. You can interpret the file using `npx next internal trace [path-to-file]`:
219219

220220
```bash
221-
npx next internal trace .next/trace-turbopack
221+
npx next internal trace .next/dev/trace-turbopack
222222
```
223223

224224
On versions where `trace` is not available, the command was named `turbo-trace-server`:
225225

226226
```bash
227-
npx next internal turbo-trace-server .next/trace-turbopack
227+
npx next internal turbo-trace-server .next/dev/trace-turbopack
228228
```
229229

230230
1. Once the trace server is running you can view the trace at https://trace.nextjs.org/.
231231
1. By default the trace viewer will aggregate timings, in order to see each individual time you can switch from "Aggregated in order" to "Spans in order" at the top right of the viewer.
232232

233-
## Still having problems?
233+
> **Good to know**: The trace file is place under the development server directory, which defaults to `.next/dev`. This is controllable using the [`isolatedDevBuild`](/docs/app/api-reference/config/next-config-js/isolatedDevBuild) flag in your Next config file.
234+
235+
### Still having problems?
234236

235237
Share the trace file generated in the [Turbopack Tracing](#turbopack-tracing) section and share it on [GitHub Discussions](https://github.com/vercel/next.js/discussions) or [Discord](https://nextjs.org/discord).

docs/01-app/03-api-reference/04-functions/revalidatePath.mdx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,13 @@ export async function GET() {
4949
}
5050
```
5151

52-
## Relationship with `revalidateTag`
52+
## Relationship with `revalidateTag` and `updateTag`
5353

54-
`revalidatePath` and [`revalidateTag`](/docs/app/api-reference/functions/revalidateTag) serve different purposes:
54+
`revalidatePath`, [`revalidateTag`](/docs/app/api-reference/functions/revalidateTag) and [`updateTag`](/docs/app/api-reference/functions/updateTag) serve different purposes:
5555

5656
- **`revalidatePath`**: Invalidates a specific page or layout path
57-
- **`revalidateTag`**: Invalidates data with specific tags across all pages that use those tags
57+
- **`revalidateTag`**: Marks data with specific tags as **stale**. Applies across all pages that use those tags
58+
- **`updateTag`**: Expires data with specific tags. Applies across all pages that use those tags
5859

5960
When you call `revalidatePath`, only the specified path gets fresh data on the next visit. Other pages that use the same data tags will continue to serve cached data until those specific tags are also revalidated:
6061

@@ -75,20 +76,22 @@ After calling `revalidatePath('/blog')`:
7576
- **Page A (/blog)**: Shows fresh data (page re-rendered)
7677
- **Page B (/dashboard)**: Still shows stale data (cache tag 'posts' not invalidated)
7778

79+
Learn about the difference between [`revalidateTag` and `updateTag`](/docs/app/api-reference/functions/updateTag#differences-from-revalidatetag).
80+
7881
### Building revalidation utilities
7982

80-
`revalidatePath` and `revalidateTag` are complementary primitives that are often used together in utility functions to ensure comprehensive data consistency across your application:
83+
`revalidatePath` and `updateTag` are complementary primitives that are often used together in utility functions to ensure comprehensive data consistency across your application:
8184

8285
```ts
8386
'use server'
8487

85-
import { revalidatePath, revalidateTag } from 'next/cache'
88+
import { revalidatePath, updateTag } from 'next/cache'
8689

8790
export async function updatePost() {
8891
await updatePostInDatabase()
8992

9093
revalidatePath('/blog') // Refresh the blog page
91-
revalidateTag('posts') // Refresh all pages using 'posts' tag
94+
updateTag('posts') // Refresh all pages using 'posts' tag
9295
}
9396
```
9497

docs/01-app/03-api-reference/04-functions/revalidateTag.mdx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ description: API Reference for the revalidateTag function.
55

66
`revalidateTag` allows you to invalidate [cached data](/docs/app/guides/caching) on-demand for a specific cache tag.
77

8+
This function is ideal for content where a slight delay in updates is acceptable, such as blog posts, product catalogs, or documentation. Users receive stale content while fresh data loads in the background.
9+
810
## Usage
911

1012
`revalidateTag` can be called in Server Functions and Route Handlers.
@@ -17,7 +19,7 @@ The revalidation behavior depends on whether you provide the second argument:
1719

1820
- **With `profile="max"` (recommended)**: The tag entry is marked as stale, and the next time a resource with that tag is visited, it will use stale-while-revalidate semantics. This means the stale content is served while fresh content is fetched in the background.
1921
- **With a custom cache life profile**: For advanced usage, you can specify any cache life profile that your application has defined, allowing for custom revalidation behaviors tailored to your specific caching requirements.
20-
- **Without the second argument (deprecated)**: The tag entry is expired immediately, and the next request to that resource will be a blocking revalidate/cache miss. This behavior is now deprecated, and you should either use `profile="max"` or migrate to `updateTag`.
22+
- **Without the second argument (deprecated)**: The tag entry is expired immediately, and the next request to that resource will be a blocking revalidate/cache miss. This behavior is now deprecated, and you should either use `profile="max"` or migrate to [`updateTag`](/docs/app/api-reference/functions/updateTag).
2123

2224
> **Good to know**: When using `profile="max"`, `revalidateTag` marks tagged data as stale, but fresh data is only fetched when pages using that tag are next visited. This means calling `revalidateTag` will not immediately trigger many revalidations at once. The invalidation only happens when any page using that tag is next visited.
2325
@@ -30,10 +32,24 @@ revalidateTag(tag: string, profile?: string): void;
3032
- `tag`: A string representing the cache tag associated with the data you want to revalidate. Must not exceed 256 characters. This value is case-sensitive.
3133
- `profile`: A string that specifies the revalidation behavior. The recommended value is `"max"` which provides stale-while-revalidate semantics. For advanced usage, this can be configured to any cache life profile that your application defines.
3234

33-
You can add tags to `fetch` as follows:
35+
Tags must first be assigned to cached data. You can do this in two ways:
36+
37+
- Using the [`next.tags`](/docs/app/guides/caching#fetch-optionsnexttags-and-revalidatetag) option with `fetch` for caching external API requests:
38+
39+
```tsx
40+
fetch(url, { next: { tags: ['posts'] } })
41+
```
42+
43+
- Using [`cacheTag`](/docs/app/api-reference/functions/cacheTag) inside cached functions or components with the `'use cache'` directive:
3444

3545
```tsx
36-
fetch(url, { next: { tags: [...] } });
46+
import { cacheTag } from 'next/cache'
47+
48+
async function getData() {
49+
'use cache'
50+
cacheTag('posts')
51+
// ...
52+
}
3753
```
3854

3955
## Returns
@@ -44,7 +60,7 @@ fetch(url, { next: { tags: [...] } });
4460

4561
`revalidateTag` invalidates data with specific tags across all pages that use those tags, while [`revalidatePath`](/docs/app/api-reference/functions/revalidatePath) invalidates specific page or layout paths.
4662

47-
> **Good to know**: These functions serve different purposes and may need to be used together for comprehensive data consistency. For detailed examples and considerations, see [Relationship with revalidateTag](/docs/app/api-reference/functions/revalidatePath#relationship-with-revalidatetag).
63+
> **Good to know**: These functions serve different purposes and may need to be used together for comprehensive data consistency. For detailed examples and considerations, see [relationship with revalidateTag and updateTag](/docs/app/api-reference/functions/revalidatePath#relationship-with-revalidatetag-and-updatetag) for more information.
4864
4965
## Examples
5066

docs/01-app/03-api-reference/04-functions/updateTag.mdx

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@ title: updateTag
33
description: API Reference for the updateTag function.
44
---
55

6-
`updateTag` allows you to update [cached data](/docs/app/guides/caching) on-demand for a specific cache tag from within Server Actions. This function is designed specifically for read-your-own-writes scenarios.
6+
`updateTag` allows you to update [cached data](/docs/app/guides/caching) on-demand for a specific cache tag from within [Server Actions](/docs/app/getting-started/updating-data).
7+
8+
This function is designed for **read-your-own-writes** scenarios, where a user makes a change (like creating a post), and the UI immediately shows the change, rather than stale data.
79

810
## Usage
911

10-
`updateTag` can **only** be called from within Server Actions. It cannot be used in Route Handlers, Client Components, or any other context.
12+
`updateTag` can **only** be called from within [Server Actions](/docs/app/getting-started/updating-data). It cannot be used in Route Handlers, Client Components, or any other context.
1113

1214
If you need to invalidate cache tags in Route Handlers or other contexts, use [`revalidateTag`](/docs/app/api-reference/functions/revalidateTag) instead.
1315

14-
> **Good to know**: `updateTag` immediately expires the cached data for the specified tag, causing the next request to that resource to be a blocking revalidate/cache miss. This ensures that Server Actions can immediately see their own writes.
16+
> **Good to know**: `updateTag` immediately expires the cached data for the specified tag. The next request will wait to fetch fresh data rather than serving stale content from the cache, ensuring users see their changes immediately.
1517
1618
## Parameters
1719

@@ -21,6 +23,26 @@ updateTag(tag: string): void;
2123

2224
- `tag`: A string representing the cache tag associated with the data you want to update. Must not exceed 256 characters. This value is case-sensitive.
2325

26+
Tags must first be assigned to cached data. You can do this in two ways:
27+
28+
- Using the [`next.tags`](/docs/app/guides/caching#fetch-optionsnexttags-and-revalidatetag) option with `fetch` for caching external API requests:
29+
30+
```tsx
31+
fetch(url, { next: { tags: ['posts'] } })
32+
```
33+
34+
- Using [`cacheTag`](/docs/app/api-reference/functions/cacheTag) inside cached functions or components with the `'use cache'` directive:
35+
36+
```tsx
37+
import { cacheTag } from 'next/cache'
38+
39+
async function getData() {
40+
'use cache'
41+
cacheTag('posts')
42+
// ...
43+
}
44+
```
45+
2446
## Returns
2547

2648
`updateTag` does not return a value.
@@ -31,12 +53,12 @@ While both `updateTag` and `revalidateTag` invalidate cached data, they serve di
3153

3254
- **`updateTag`**:
3355
- Can only be used in Server Actions
34-
- Immediately expires the cache entry (blocking revalidate on next visit)
56+
- Next request waits for fresh data (no stale content served)
3557
- Designed for read-your-own-writes scenarios
3658

3759
- **`revalidateTag`**:
3860
- Can be used in Server Actions and Route Handlers
39-
- With `profile="max"` (recommended): Uses stale-while-revalidate semantics
61+
- With `profile="max"` (recommended): Serves cached data while fetching fresh data in the background (stale-while-revalidate)
4062
- With custom profile: Can be configured to any cache life profile for advanced usage
4163
- Without profile: legacy behavior which is equivalent to `updateTag`
4264

@@ -59,11 +81,13 @@ export async function createPost(formData: FormData) {
5981
data: { title, content },
6082
})
6183

62-
// Update the cache so the new post is immediately visible
84+
// Invalidate cache tags so the new post is immediately visible
85+
// 'posts' tag: affects any page that displays a list of posts
6386
updateTag('posts')
87+
// 'post-{id}' tag: affects the individual post detail page
6488
updateTag(`post-${post.id}`)
6589

66-
// Redirect to the new post
90+
// Redirect to the new post - user will see fresh data, not cached
6791
redirect(`/posts/${post.id}`)
6892
}
6993
```
@@ -83,11 +107,13 @@ export async function createPost(formData) {
83107
data: { title, content },
84108
})
85109

86-
// Update the cache so the new post is immediately visible
110+
// Invalidate cache tags so the new post is immediately visible
111+
// 'posts' tag: affects any page that displays a list of posts
87112
updateTag('posts')
113+
// 'post-{id}' tag: affects the individual post detail page
88114
updateTag(`post-${post.id}`)
89115

90-
// Redirect to the new post
116+
// Redirect to the new post - user will see fresh data, not cached
91117
redirect(`/posts/${post.id}`)
92118
}
93119
```
@@ -98,11 +124,11 @@ export async function createPost(formData) {
98124
import { updateTag } from 'next/cache'
99125

100126
export async function POST() {
101-
// This will throw an error
127+
// This will throw an error
102128
updateTag('posts')
103129
// Error: updateTag can only be called from within a Server Action
104130

105-
// Use revalidateTag instead in Route Handlers
131+
// Use revalidateTag instead in Route Handlers
106132
revalidateTag('posts', 'max')
107133
}
108134
```

docs/01-app/03-api-reference/08-turbopack.mdx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,17 +224,19 @@ If you encounter performance or memory issues and want to help the Next.js team
224224
NEXT_TURBOPACK_TRACING=1 next dev
225225
```
226226

227-
This will produce a `.next/trace-turbopack` file. Include that file when creating a GitHub issue on the [Next.js repo](https://github.com/vercel/next.js) to help us investigate.
227+
This will produce a `.next/dev/trace-turbopack` file. Include that file when creating a GitHub issue on the [Next.js repo](https://github.com/vercel/next.js) to help us investigate.
228+
229+
By default the development server outputs to `.next/dev`. Read more about [isolatedDevBuild](/docs/app/api-reference/config/next-config-js/isolatedDevBuild).
228230

229231
## Summary
230232

231233
Turbopack is a **Rust-based**, **incremental** bundler designed to make local development and builds fast—especially for large applications. It is integrated into Next.js, offering zero-config CSS, React, and TypeScript support.
232234

233235
## Version Changes
234236

235-
| Version | Changes |
236-
| --------- | ----------------------------------------------------------------------------------------------------------------- |
237-
| `v16.0.0` | Turbopack becomes the default bundler for Next.js. Automatic support for Babel when a configuration file is found |
238-
| `v15.5.0` | Turbopack support for `build` beta |
239-
| `v15.3.0` | Experimental support for `build` |
240-
| `v15.0.0` | Turbopack for `dev` stable |
237+
| Version | Changes |
238+
| --------- | ------------------------------------------------------------------------------------------------------------------ |
239+
| `v16.0.0` | Turbopack becomes the default bundler for Next.js. Automatic support for Babel when a configuration file is found. |
240+
| `v15.5.0` | Turbopack support for `build` beta |
241+
| `v15.3.0` | Experimental support for `build` |
242+
| `v15.0.0` | Turbopack for `dev` stable |

0 commit comments

Comments
 (0)