Next.js Discord

Discord Forum

Making NextJS make difference between /products/[number].js & /products/[string].js

Unanswered
Californian posted this in #help-forum
Open in Discord
CalifornianOP
I've got a product configurator living in /products/123 path. I can't change the path of it for external reasons. Product's ID is always a number.
Also I want to create a "trait" discovery page for products which would use a slug as a name, which is never an integer. For example /products/black.

Of course it doesn't work so far because NextJS considers both of the paths to be the same one.
I don't want to bundle both of these pages' logic into one file eg. /products/[id_or_trait].js because it would turn into ape sh*t real fast.

Is there any way to achieve that? Has anyone tried before?

1 Reply