How to get query params using Server component (next 13)

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

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)