building route handler adds an extra unneccesary rsc file
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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