I am creating platform that has pagination in layout. I don’t want to make this layout client side for SEO and Speed. How can I access my searchParams in layout component with SSR ?
I am creating platform that has pagination in layout. I don’t want to make this layout client side for SEO and Speed. How can I access my searchParams in layout component with SSR ?
2
Answers
If you are using nextjs App router, you can use the userSearchParams hook to do that, simply by having the next code:
You can find further details in the official docs
you should be able to do like below
Please check the docs https://nextjs.org/docs/app/api-reference/file-conventions/page#searchparams-optional