Using app router, how to read query params on server
Answered
Gouty oak gall posted this in #help-forum
Gouty oak gallOP
Inside of a page.tsx what is best way to read a query param (e.g. ?field=val) to pass it to a component? All the docs show useSearchParams but that is clientside isn't it?
Answered by B33fb0n3
You can use the queryparams from the params: https://nextjs.org/docs/app/api-reference/file-conventions/page#searchparams-optional
4 Replies
@Gouty oak gall Inside of a page.tsx what is best way to read a query param (e.g. ?field=val) to pass it to a component? All the docs show useSearchParams but that is clientside isn't it?
You can use the queryparams from the params: https://nextjs.org/docs/app/api-reference/file-conventions/page#searchparams-optional
Answer
Gouty oak gallOP
Yep that did it for me. Thanks!