Next.js Discord

Discord Forum

Catch all segments with dynamic route within

Unanswered
Cape horse mackerel posted this in #help-forum
Open in Discord
Cape horse mackerelOP
Hello guys. Is it possible to have catch all segments with dynamic route within?
I want to have something like
`-- item
    |-- [...slug]
    |   `-- media
    |       `-- [mediaId]
    |           `-- page.tsx
    `-- page.tsx

3 Replies

@Cape horse mackerel Hello guys. Is it possible to have catch all segments with dynamic route within? I want to have something like ts `-- item |-- [...slug] | `-- media | `-- [mediaId] | `-- page.tsx `-- page.tsx
I doubt it is possible. Try it, if you see an error then it isn’t possible.

Most likely you need to have only one […slug]/page.tsx and you have to check for the existence of "media" and the value of mediaId in the slug array
Cape horse mackerelOP
Maybe to remove the slug completely and use smth like
`-- item
    `-- [dynamicRouteOne]
        `-- [itemId]
            `-- media
                `-- page.tsx
@Cape horse mackerel Maybe to remove the slug completely and use smth like ts `-- item `-- [dynamicRouteOne] `-- [itemId] `-- media `-- page.tsx
yes that's better. catch-alls should only be used when the number of segments is unknown