[Next 15 RC2] Question about Search Params / Params + Suspense
Unanswered
Short-tailed Hawk posted this in #help-forum
Short-tailed HawkOP
Now that search params and params are async functions, do I have to wrap the component using them in a Suspense?
21 Replies
oki so
@Short-tailed Hawk
params in layout.js, page.js, route.js, default.js, generateMetadata, and generateViewport
searchParams in page.js
searchParams in page.js
since its only the page.ts/js which got hit with the breaking change.. you dont need suspense (you cant really wrap it in suspense anyways lol)
you just need to await them
you just need to await them
for stuff like client components using useSearchParams.. you always had to wrap in suspense
Short-tailed HawkOP
Oh I see, thanks!
np, any other questions with rc2 lemme know, i was watching the stream lee did regarding rc2
go through it if needed, its helpful for the breaking change
Short-tailed HawkOP
The reason I asked is because I remember reading somewhere that when PPR launches, you will need to wrap async operations around Suspense, so I figured out that if Im at a Page file, and just pass the searchParams or params props to a child component which is an Async Component, would I need to wrap that child component in a Suspense or not?
im wondering why you would need to pass a promise to a child anyways
if you are fetching in it already.. you would have already wrapped it in suspense
or else if your just passing paramd and stuff, await it in the page itself xD, no need to send over promises and stuff
How should you do searchparams with nextjs 15 in a "use server"?
{
params,
searchParams,
}: {
params: { slug: string }
searchParams: { [key: string]: string | string[] | undefined }
}
This doesnt work anymore?
params,
searchParams,
}: {
params: { slug: string }
searchParams: { [key: string]: string | string[] | undefined }
}
This doesnt work anymore?
are you on rc2?
no
didnt knew there was rc2
make your own forum post please.
If you did do that then yes you would need to wrap that component in Suspense, otherwise you can just consume it within your page which should be wrapped with Suspense as well (loading.tsx)
@Short-tailed Hawk if your questions are solved, please mark an answer