#HOw to get params in next13

1 messages · Page 1 of 1 (latest)

burnt jewel
#

/credit-cards?page=1

how to get page=1 in next 13?

raw turtleBOT
#

Hi @burnt jewel. 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 13, you can access the search parameters of a URL in your server components using the searchParams prop. This prop is available in the page.js component and in the generateMetadata function.

Here is an example of how you can use it in a page.js component:

export default function Page({ searchParams }) {
  const { page } = searchParams;
  // ...
}

In the above example, page will hold the value of the page query parameter from the URL (e.g., 1 from /credit-cards?page=1).

For more details, you can refer to the Next.js documentation on useSearchParams (https://nextjs.org/docs/app/api-reference/functions/use-search-params#pages).

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