Next.js Discord

Discord Forum

[Next 15 RC2] Question about Search Params / Params + Suspense

Unanswered
Short-tailed Hawk posted this in #help-forum
Open in Discord
Avatar
Short-tailed HawkOP
Now that search params and params are async functions, do I have to wrap the component using them in a Suspense?

20 Replies

Avatar
oki so
@Short-tailed Hawk
params in layout.js, page.js, route.js, default.js, generateMetadata, and generateViewport
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
for stuff like client components using useSearchParams.. you always had to wrap in suspense
Avatar
Short-tailed HawkOP
Oh I see, thanks!
Avatar
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
Avatar
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?
Avatar
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
Avatar
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?
Avatar
are you on rc2?
Avatar
no
didnt knew there was rc2
Avatar
make your own forum post please.
Avatar
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)