Next.js Discord

Discord Forum

Search Params async /await bug?

Answered
Cornish Rex posted this in #help-forum
Open in Discord
Avatar
Cornish RexOP
Hey guys im trying to access the search params simply as mentioned from the docs exactly:
const page = async ({ searchParams }: SearchParamsProps) => {
    console.log(await searchParams);
}

Doing that shows:
'await' has no effect on the type of this expression.

removing await i get:
Error: Route "/shop" used `searchParams.page`. `searchParams` should be awaited before using its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis

Nextjs 15, any idea what the issue here is?
Answered by joulev
Your type SearchParamsProps is wrong
View full answer

3 Replies

Avatar
Your type SearchParamsProps is wrong
Answer
Avatar
Make the searchParams in there a Promise and you’ll be good
Avatar
Cornish RexOP
Didn't really know that is possible! thank you 🙂