Next.js Discord

Discord Forum

How can I access dynamic routes params inside an SSC?

Answered
Polar bear posted this in #help-forum
Open in Discord
Polar bearOP
hello everyone am trying to access the dynamic routes param in a server component to make a dynamic request using that specific data?
Answered by riský
so you have done the code to get the params right?
export default function Page({ params }: { params: { slug: string } }) {
  return <div>My Post: {params.slug}</div>
}
View full answer

5 Replies

Polar bearOP
ya I couldn't access it on the server component
so you have done the code to get the params right?
export default function Page({ params }: { params: { slug: string } }) {
  return <div>My Post: {params.slug}</div>
}
Answer
Polar bearOP
Ya thanks I forgot about this I migrated to Next 13 and I had to replace the getServerSideprops and I wasn't able to find the context their that's why, Thanks tho 👍
Nice! (Mark as solution? So that other know it's solved :))