Closed
Description
Link to the code that reproduces this issue
https://github.com/pfilipak/nextjs-context-bug-example.git
To Reproduce
Describe the Bug
When creating a dynamic API route (e.g. app/api/employee-shifts/[id]/route.ts
), the generated type in .next/types/app/api/employee-shifts/[id]/route.ts
expects the context parameter to be:
{ params: Promise<{ id: string }> }
However, according to the Next.js documentation, the correct type should be:
{ params: { id: string } }
This causes the following build error:
Type '{ id: string; }' is missing the following properties from type 'Promise<any>': then, catch, finally, [Symbol.toStringTag]
To Reproduce
- Create a dynamic API route:
app/api/employee-shifts/[id]/route.ts
- Use the documented handler signature:
export async function GET(_req: NextRequest, context: { params: { id: string } }) { ... }
- Run
next build
- Observe the type error referencing
.next/types/app/api/employee-shifts/[id]/route.ts
Workaround
Changing the handler to:
export async function GET(_req: NextRequest, context: { params: Promise<{ id: string }> }) {
const { id } = await context.params;
// ...
}
allows the build to succeed, but this is not the documented or expected API.
Current vs. Expected behavior
Expected Behavior
The generated types in .next/types
should expect params
to be an object, not a Promise, matching the documentation and previous Next.js behavior.
Provide environment information
**What version of Next.js are you using?**
next: 15.3.3
typescript: 5.x
react: 19.x
@types/react: 19.x
**What version of Node.js are you using?**
node: 22.14.0
Which area(s) are affected? (Select all that apply)
Route Handlers
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
Additional Context
- The error persists even after cleaning
.next
andnode_modules
, and reinstalling dependencies. - The issue only resolves with the workaround above.