Next.js Discord

Discord Forum

How to Handle Server-Side Data Fetching with Search Params for Globally Available Component

Unanswered
Snowshoe posted this in #help-forum
Open in Discord
SnowshoeOP
I have a <SearchTokensDrawer /> component that was previously a client component in my rootLayout to provide global search. Now I want to move data fetching to a server component and pass the result to the client. However, since searchParams are only available in page components (not layouts), I can’t keep this logic in rootLayout anymore. What’s the best practice to make this component globally available without duplicating logic in every page?

0 Replies