nextjs - 💡(How to fix) Fix Incorrect rendering after redirect/router when cacheComponents is enabled [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#85660Fetched 2026-04-08 02:14:39
View on GitHub
Comments
2
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
commented ×2closed ×1issue_type_added ×1labeled ×1

Code Example

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:43 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T8132
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 24.11.0
  npm: 11.6.1
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.0.1 // Latest available version is detected (16.0.1).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/jeanzuck/next16-cachecomponents-demo

To Reproduce

  1. git clone https://github.com/jeanzuck/next16-cachecomponents-demo
  2. npm install
  3. npm run dev
  4. Click Protected Link
  5. Click Login Button
  6. Observe that the page still shows /login instead of /protected

Issue deployment: https://next16-cachecomponents-demo.vercel.app/

Current vs. Expected behavior

Current Behavior

  1. Clicking the /protected link redirects to /login.
  2. Clicking the Login button calls a server action to set a cookie and then redirects back to /protected.
  3. The issue: the page still displays /login.
  4. Clicking the Login button again finally shows /protected correctly.

Expected Behavior

  1. Clicking the /protected link redirects to /login.
  2. Clicking the Login button calls a server action to set a cookie and then redirects back to /protected.
  3. The /protected page should render correctly right after the redirect.

Attempts to fix the issue by:

  • Adding revalidatePath()
  • Replacing server-side redirect() with client-side router.push() or router.replace()

did not resolve the problem.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:43 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T8132
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 24.11.0
  npm: 11.6.1
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.0.1 // Latest available version is detected (16.0.1).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

cacheComponents

Which stage(s) are affected? (Select all that apply)

next dev (local), Vercel (Deployed)

Additional context

This issue occurs only when cacheComponents is enabled.
Disabling it restores normal rendering and redirect behavior.

extent analysis

TL;DR

  • The issue with the page still showing /login instead of /protected after login can be addressed by investigating the caching behavior of cacheComponents in Next.js.

Guidance

  • Verify that the cacheComponents configuration is correctly set up and understand its implications on server-side rendering and redirects.
  • Check the server action that sets the cookie and redirects back to /protected to ensure it is properly handling the caching headers.
  • Investigate potential conflicts between cacheComponents and the redirect mechanism, considering the use of revalidatePath() or client-side redirects.
  • Test the application with cacheComponents disabled to confirm that the issue is indeed related to caching.

Example

  • No specific code example can be provided without further details on the implementation of cacheComponents and the server action.

Notes

  • The issue seems to be closely related to the cacheComponents feature in Next.js, and understanding its caching behavior is crucial to resolving the problem.
  • The provided environment information and package versions are noted, but without more specific details on the code, it's challenging to provide a precise solution.

Recommendation

  • Apply workaround: Temporarily disable cacheComponents to ensure normal rendering and redirect behavior, while further investigating the caching configuration and its interaction with server-side redirects.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING