#How do I access url params in an RSC?

1 messages · Page 1 of 1 (latest)

weak peakBOT
#

Hi @warm hatch. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

In Next.js, to access query parameters in a Server Component, you can use the searchParams prop. This prop is available in the page.js component and in the generateMetadata function. When client navigations update search parameters, a new request is sent to the server, causing a re-render.

Here is the relevant documentation for the searchParams prop: Next.js Documentation (https://nextjs.org/docs/app/api-reference/file-conventions/page#searchparams-optional)

Please note that if you are using Client Components, you can use the useSearchParams hook to access the current query parameters. Here is the relevant documentation for the useSearchParams hook: Next.js Documentation (https://nextjs.org/docs/app/api-reference/functions/use-search-params)

Remember that the usage of these APIs depends on whether you are working with Server Components or Client Components.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: