Next.js Discord

Discord Forum

Error when building async params

Unanswered
Saltwater Crocodile posted this in #help-forum
Open in Discord
Saltwater CrocodileOP
anyone have error when build?
error
app/(member)/member/[memberid]/[name]/@funfact/page.tsx
Type error: Type '{ params: { memberid: string; name: string; }; }' does not satisfy the constraint 'PageProps'.
Types of property 'params' are incompatible.
Type '{ memberid: string; name: string; }' is missing the following properties from type 'Promise<any>': then, catch, finally, [Symbol.toStringTag]

the code inside a dynamic route [memberid]/[name]/page.tsx
export default async function Page({
params,
}: {
params: { memberid: string; name: string };
}) {
const {memberid} = await params
const funfactResponse = await GetFunfact(memberid);


due to async next 15 i though we need to async the params

10 Replies

Saltwater CrocodileOP
change the type then your code should be good already
Saltwater CrocodileOP
that is weird even though i use your code which a promise still an error
app/(member)/member/[memberid]/[name]/@profile/page.tsx
Type error: Type '{ params: { memberid: string; name: string; }; }' does not satisfy the constraint 'PageProps'.
Types of property 'params' are incompatible.
Type '{ memberid: string; name: string; }' is missing the following properties from type 'Promise<any>': then, catch, finally, [Symbol.toStringTag]

Static worker exited with code: 1 and signal: null
Pixiebob
once try this

type PageProps= {
params: Promise<{ memberid: string
name: string; }>
}