Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[App Router] redirect() causes the target page to be server-rendered twice when navigated via <Link> #78493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
lp0ql opened this issue Apr 24, 2025 · 1 comment
Labels
Linking and Navigating Related to Next.js linking (e.g., <Link>) and navigation.

Comments

@lp0ql
Copy link

lp0ql commented Apr 24, 2025

Link to the code that reproduces this issue

https://github.com/lp0ql/next-15.3.1-double-server-side-rendering

To Reproduce

Describe the Bug

When a user clicks a (next/link) that points to a route where the server component calls redirect(), the target page appears to be server-rendered twice.

  • Does not happen in v14 (tested with 14.2.28).
  • Does not happen in production (npm run build && npm run start).
  • Does not happen when reactStrictMode is false in next.config.js

Steps to Reproduce

The repository contains three sub-directories:

Directory Next.js version Purpose
15 15.3.1 A Next.js app that contains an in-app explanation of the issue and links that trigger the bug. It also includes a scenario that mimics a real-world use case, so you can reproduce the problem while reading the description.
14 14.2.28 Identical to 15 except that it uses Next.js 14. Running this directory shows that the bug does not occur in v14.
15-reproduction-template 15.x(canary) The structure follows the official “reproduction-template” starter used in Next.js issues.

To verify the regression:

  1. git clone https://github.com/lp0ql/next-15.3.1-double-server-side-rendering
  2. cd next-15.3.1-double-server-side-rendering/15 or cd next-15.3.1-double-server-side-rendering/15-reproduction-template
  3. npm install
  4. npm run dev
  5. Open http://localhost:3000
  6. Click link
  7. Watch the dev-server terminal — you should see the same log line appear twice.

If you repeat the same procedure inside the 14 directory, the log appears only once, confirming that this is a v15-specific regression.

Current vs. Expected behavior

Current Expected
// click next link
MinimumSetup
Minimum Setup Result
Minimum Setup Result
// click next link
MinimumSetup
Minimum Setup Result

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.4.0: Fri Apr 11 18:33:24 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_VMAPPLE
  Available memory (MB): 8192
  Available CPU cores: 8
Binaries:
  Node: 22.1.0
  npm: 10.7.0
  Yarn: N/A
  pnpm: 10.9.0
Relevant Packages:
  next: 15.3.1 // Latest available version is detected (15.3.1).
  eslint-config-next: 15.3.1
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.8.3
Next.js Config:
  output: N/A

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

Linking and Navigating

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

next dev (local)

Additional context

First-time reporter—sorry in advance if I missed anything.
Big thanks to the Next.js team for your awesome work!

@github-actions github-actions bot added the Linking and Navigating Related to Next.js linking (e.g., <Link>) and navigation. label Apr 24, 2025
@makezi
Copy link

makezi commented Apr 24, 2025

I'm also experiencing the same issue on v15.3.1. I made a codesandbox repo here that reproduces the issue. If you click the link which navigates to page /one which has a redirect to /two then /two renders twice:

GET / 200 in 57ms (CLICK LINK)

GET /one 200 in 78ms (REDIRECT)

GET /two 200 in 101ms (RENDER #1)
GET /two 200 in 115ms (RENDER #2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Linking and Navigating Related to Next.js linking (e.g., <Link>) and navigation.
Projects
None yet
Development

No branches or pull requests

2 participants