vercel / vercel/next.js

layout.tsx renders twice when using SSR and parallel routes

Open
#76,410 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Parallel & Intercepting Routes Performance
Dominant language
JavaScript
Stars
142k
Forks
32.4k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

Link to the code that reproduces this issue

https://github.com/eiiot/next-routes-rerendering

To Reproduce
  1. Build the application with next build
  2. Run with next start
Current vs. Expected behavior

RootLayout rendered is logged twice per request when it should only be logged once. This causes a bunch of issues, including fetching data from APIs twice.

Provide environment information
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.1.0: Thu Oct 10 21:03:11 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T6020
  Available memory (MB): 32768
  Available CPU cores: 12
Binaries:
  Node: 20.11.0
  npm: 10.2.4
  Yarn: 4.1.0
  pnpm: N/A
Relevant Packages:
  next: 15.2.0-canary.71
  eslint-config-next: 15.2.0-canary.71
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.7.3
Next.js Config:
  output: N/A
Which area(s) are affected? (Select all that apply)

Performance, Parallel & Intercepting Routes

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

next dev (local), next build (local), next start (local), Vercel (Deployed)

Additional context

This seems to be a fairly old issue: see this reddit thread discussing v14.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked reproduction repository and inspect layout.tsx. Run next build followed by next start, then observe the RootLayout rendered logs for a request using parallel routes. The issue is done when the layout renders once per request and the reproduction no longer shows duplicate API fetching.

Written by the indexing model from the issue text.

Assessment

Tech stack
nextjs, react, typescript
Domain
frontend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.