How can I access dynamic routes params inside an SSC?
Answered
Polar bear posted this in #help-forum
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>
}5 Replies
@Polar bear hello everyone am trying to access the dynamic routes param in a server component to make a dynamic request using that specific data?
something like: https://nextjs.org/docs/app/building-your-application/routing/dynamic-routes#example
like is your page something like:
like is your page something like:
app/[id]/page.tsxPolar 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 :))