[Bug] Dynamic Route Type Error: params inferred as Promise in .next/types for [userId] page #80439
Replies: 4 comments
-
Hi, Next 15 introduced breaking changes, documented here:
You need to change your code to: // src/app/admin/user/[userId]/page.tsx
export async function Page({ params }: { params: Promise<{ userId: string }> }) {
const { userId } = await params
} |
Beta Was this translation helpful? Give feedback.
-
@blessibles I see a fix was attempted, but there was a crucial detail left out, that this page is // src/app/admin/user/[userId]/page.tsx
'use client'
import { use } from 'react';
// other code
export default function Page({ params }: { params: Promise<{ userId: string }> }) {
const { userId } = use (params);
const [user, setUser] = useState<User | null>(null); This was also documented, in one of the links I left above, https://nextjs.org/docs/app/api-reference/file-conventions/page#reading-searchparams-and-params-in-client-components |
Beta Was this translation helpful? Give feedback.
-
Thank you!
I just applied this 😊
From: Joseph ***@***.***>
Sent: Wednesday, June 11, 2025 1:00 PM
To: vercel/next.js ***@***.***>
Cc: blessibles ***@***.***>; Mention ***@***.***>
Subject: Re: [vercel/next.js] [Bug] Dynamic Route Type Error: params inferred as Promise in .next/types for [userId] page (Issue #80296)
<https://avatars.githubusercontent.com/u/21013447?s=20&v=4> icyJoseph left a comment (vercel/next.js#80296) <#80296 (comment)>
@blessibles <https://github.com/blessibles> I see a fix was attempted, but there was a crucial detail left out, that this page is use client:
// src/app/admin/user/[userId]/page.tsx
'use client'
import { use } from 'react';
// other code
export default function Page({ params }: { params: Promise<{ userId: string }> }) {
const { userId } = use (params);
const [user, setUser] = useState<User | null>(null);
This was also documented, in one of the links I left above, https://nextjs.org/docs/app/api-reference/file-conventions/page#reading-searchparams-and-params-in-client-components
—
Reply to this email directly, view it on GitHub <#80296 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/BSUHZ5XG33ZMOXS7UMOZLH33DBVDFAVCNFSM6AAAAAB63J3L76VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSNRTG4YDSNZSGI> .
You are receiving this because you were mentioned. <https://github.com/notifications/beacon/BSUHZ5SZ2NMRZ7OGEA4CQF33DBVDFA5CNFSM6AAAAAB63J3L76WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTVQU2PRU.gif> Message ID: ***@***.*** ***@***.***> >
|
Beta Was this translation helpful? Give feedback.
-
I will move this into a discussion thread. I think the root issue has been identified. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Link to the code that reproduces this issue
https://github.com/blessibles/blessibles-cursor
To Reproduce
Current vs. Expected behavior
When building a dynamic route at src/app/admin/user/[userId]/page.tsx, the build fails with a type error:
Type '{ params: { userId: string; }; }' is missing the following properties from type 'Promise': then, catch, finally, [Symbol.toStringTag]
The generated .next/types/app/admin/user/[userId]/page.ts expects params to be a Promise, which is not correct for a dynamic route page.
This error persists even after:
The error always references the same generated type file, even after all caches are cleared and the route is renamed.
Expected:
The build should succeed, and the generated types should expect params to be an object, not a Promise, for a dynamic route page.
Provide environment information
Which area(s) are affected? (Select all that apply)
Not sure
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
This error is reproducible in a fresh Next.js project with only the relevant files copied over. All troubleshooting steps from the official docs and community have been exhausted.
With the help of an expert assistant, I have systematically tried all of the following:
Removed all explicit type annotations from the page and used only inline types.
Deleted all build artifacts and caches: .next, .next/types, node_modules, package-lock.json.
Performed a full clean install of all dependencies.
Renamed the dynamic route folder (e.g., from [userId] to [uid] and [userPageId]).
Deleted stale type files in .next/types.
Moved the page to a new dynamic route in a fresh folder.
Created a brand new Next.js project using npx create-next-app, copied only the source files and configs, and tried building there.
Tried disabling type checking with // @ts-nocheck and NEXT_IGNORE_TYPE_ERRORS=true.
Checked for custom or global type definitions that could interfere (none found).
Confirmed all versions of Next.js and TypeScript are compatible and up to date.
**The attached ZIP file contains:
The error persists in all cases, and always references the same generated type file, even after all caches are cleared and the route is renamed.
Zipped.zip
Beta Was this translation helpful? Give feedback.
All reactions