Regression: await params behaviour differs when called from generateMetadata vs default function
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/ctolkien/next-route-params-issue
To Reproduce
Browse to /products/foo%20bar
This code is running const { productId } = await params; in both the default export function as well as the generateMetaData function. Observe in the server logs that there are differences in what decoding has taken place:
[Page] raw productId: "foo%20bar"
[Page] char codes: [
102, 111, 111, 37,
50, 48, 98, 97,
114
]
[generateMetadata] raw productId: "foo bar"
[generateMetadata] char codes: [
102, 111, 111, 32,
98, 97, 114
]
The generateMetadata version has been url decoded, where as the one in another function has not.
This was introduced in 16.2.0-canary.54, seemingly by https://github.com/vercel/next.js/pull/90249. I do not think the change of behaviour was intentional.
Current vs. Expected behavior
The results of await params should be consistent.
Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 11 Enterprise
Available memory (MB): 65422
Available CPU cores: 16
Binaries:
Node: 24.13.1
npm: 11.8.0
Yarn: N/A
pnpm: 11.9.0
Relevant Packages:
next: 16.3.0-preview.5 // Latest available version is detected (16.3.0-preview.5).
eslint-config-next: N/A
react: 18.3.1
react-dom: 18.3.1
typescript: 5.9.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Dynamic Routes
Which stage(s) are affected? (Select all that apply)
next dev (local), Other (Deployed)
Additional context
No response
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
Start with the linked next-route-params-issue reproduction and browse to /products/foo%20bar, comparing await params in the default export and generateMetadata. Review the behavior introduced around PR 90249 and trace the Dynamic Routes parameter handling. Done means both entry points produce consistent decoded values, with the reproduction confirming the result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, next.js, react
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100