Next.js Discord

Discord Forum

How to get full route access in server components such as layout?

Unanswered
Irish Water Spaniel posted this in #help-forum
Open in Discord
Irish Water SpanielOP
Hello everyone!
I am building a NextJS application with the following URL scheme:
http://website.example.org/businesses/[business_id]/posts/[post_id]/comments/[comment_id]
The data is stored in an API with an identical structure:
http://data.example.org/businesses/[business_id]/posts/[post_id]/comments/[comment_id]
Thus, when a user navigates to http://website.example.org/businesses/business_1/posts/post_2/comments/comment_3, the page will need to perform a fetch request to the corresponding API url, and I need to know the slugs for [business_id] and [post_id].

My question is, how do I obtain the [business_id] and [post_id] slugs in the [comment_id] page? The documentation only limits itself by showing how to get the last slug:
export default function Page({ params }: { params: { slug: string } }) {
  return <div>My Post: {params.slug}</div>
}

But how can I get the others?

3 Replies