vercel / vercel/next.js

building route handler adds an extra unneccesary rsc file

Open
#97,564 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dynamic Routes Output Route Handlers
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/davecarlson/nextjs-route-handler-rsc-routes-repro

To Reproduce

To Reproduce

1. Clone https://github.com/davecarlson/nextjs-route-handler-rsc-routes-repro
2. npm install
3. npm run build
4. npm run verify:files
Current vs. Expected behavior

I see an extra file being created, meaning on large projects you can hit the Routes created per Deployment in 2x time.

I expect the number of handlers outputs to match the number of route handlers, and the extra .rsc .rsc.segment to not be created

For example, this gets created:
/api/[tenantId].rsc
/api/[tenantId]
/api/[tenantId]/items.rsc
/api/[tenantId]/items
/api/[tenantId]/items/[itemId].rsc
/api/[tenantId]/items/[itemId]

Provide environment information
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.6.0: Fri Jul 31 19:19:08 PDT 2026; root:xnu-12377.161.14~5/RELEASE_ARM64_T6050
  Available memory (MB): 65536
  Available CPU cores: 18
Binaries:
  Node: 24.18.0
  npm: 11.16.0
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.3.1 // Latest available version is detected (16.3.1).
  eslint-config-next: N/A
  react: 19.2.8
  react-dom: 19.2.8
  typescript: N/A
Next.js Config:
  output: N/A
Which area(s) are affected? (Select all that apply)

Route Handlers, Dynamic Routes, Output

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

Build (Local), Vercel (Deployed)

Additional context

Checked with latest canary build - same issue exists.

I have a vercel build that fails due to hitting the limit : AhJzCWvPRMin8Lez85Q2CQQcqYn4

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

Clone the linked nextjs-route-handler-rsc-routes-repro repository and run npm install, npm run build, and npm run verify:files to confirm the extra outputs. Trace the build handling for dynamic route handlers and compare the generated files with the listed route handlers; done means the unnecessary .rsc and .rsc.segment outputs are no longer created.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nextjs, react
Domain
backend, build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.