I don’t think it’s currently possible to do this in an arbitrary component. However, it is possible to access query parameters in page.tsx files, and pass these down to your components via props.
export default function Page({
params,
searchParams,
}: {
params: { slug: string };
searchParams?: { [key: string]: string | string[] | undefined };
}) {
return <h1>{searchParams?.greeting || "Hello!"}</h1>;
}
See the Docs