Next.js Discord

Discord Forum

Need a guide to Next 15 PageProps

Answered
Chum salmon posted this in #help-forum
Open in Discord
Chum salmonOP
I'm getting this error when building in Vercel.
Type error: Type '{ searchParams?: { [key: string]: string | string[] | undefined; } | undefined; }' does not satisfy the constraint 'PageProps'.

Could somebody please link me to the doc where I can get more info about this PageProps?
Answered by Chum salmon
It's working now without error!
So basically I have to mark it as promise and before using it I have to use await props.searchParams like this:

export default async function Home(props: {
    searchParams: Promise<{ logout?: string }>;
  }) {
    const searchParams = await props.searchParams;
    const logoutSuccess = searchParams?.logout === "1";


Thanks again šŸ™‚
View full answer

4 Replies

@Dutch show some code
Chum salmonOP
I just found this page so I'm doing my testing right now and see if it works.
https://nextjs.org/docs/app/guides/upgrading/version-15#asynchronous-page

If it doesn't work I'll get back and put the code here. Thank you for reaching out.
Dutch
cuz i have searchParams and dont have error
@Dutch cuz i have searchParams and dont have error
Chum salmonOP
It's working now without error!
So basically I have to mark it as promise and before using it I have to use await props.searchParams like this:

export default async function Home(props: {
    searchParams: Promise<{ logout?: string }>;
  }) {
    const searchParams = await props.searchParams;
    const logoutSuccess = searchParams?.logout === "1";


Thanks again šŸ™‚
Answer