Unverified Commit 495d50f1 authored by Aurora Scharff's avatar Aurora Scharff Committed by GitHub

docs: document revalidateTag's required second argument in upgrade guide (#92134)

### What?

Add a before/after migration snippet to the version 16 upgrade guide
showing the old single-argument `revalidateTag('posts')` and the new
required two-argument `revalidateTag('posts', 'max')` signature. Also
mention the TypeScript error users will see and the `updateTag`
alternative for immediate expiration.

### Why?

Users upgrading from Next.js 15 to 16 encounter `Expected 2 arguments,
but got 1` when using the old single-argument syntax. The upgrade guide
previously only showed the new code without showing the old pattern,
requiring users to search externally to understand what changed.

### How?

- Added a concise `// Before` / `// After` code block showing the
migration, matching the convention used elsewhere in the upgrade guide
(e.g. `next/legacy/image`)
- Added a note that the single-argument form produces a TypeScript error
- Added a note pointing to `updateTag` as the alternative for immediate
expiration
- Kept the original full example with stale-while-revalidate behavior
explanation

## PR checklist (Improving Documentation)

- Run `pnpm prettier-fix` to fix formatting issues before opening the PR
- Follow the docs contribution guide:
https://nextjs.org/docs/community/contribution-guide
parent d6ff2197
......@@ -454,7 +454,17 @@ bun add -D babel-plugin-react-compiler
### revalidateTag
[`revalidateTag`](/docs/app/api-reference/functions/revalidateTag) has a new function signature. You can pass a [`cacheLife`](/docs/app/api-reference/functions/cacheLife#reference) profile as the second argument.
[`revalidateTag`](/docs/app/api-reference/functions/revalidateTag) now requires a second argument specifying a [`cacheLife`](/docs/app/api-reference/functions/cacheLife#reference) profile. The single-argument form is deprecated and will produce a TypeScript error.
```ts
// Before
revalidateTag('posts')
// After
revalidateTag('posts', 'max')
```
If you need immediate expiration rather than stale-while-revalidate, use [`updateTag`](/docs/app/api-reference/functions/updateTag) in Server Actions instead.
```ts filename="app/actions.ts" switcher
'use server'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment