'Dynamic routing for NextJS online store

I need to create a path like /catalog/[categoryId]/[...subcategoryId]/[productId]

[categoryId] - The page of the main category itself. There is a separate template for it.

[...subcategoryId] - The page or several pages of subcategories. For example clothes/shirts/ or maybe clothes/pants/jeans.

[productId] - The product itself

I relied on next.js documentation for routing

How do I do it correctly using NextJS?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source