Partial match for dynamic routes #15690
Replies: 3 comments 2 replies
-
@WingmanImd I like your idea to have partial matches. In my case I would use something like The workaround as you wrote can be enhaced by |
Beta Was this translation helpful? Give feedback.
-
I really hope some dev sees this post and makes it a reality. I really want to do things like |
Beta Was this translation helpful? Give feedback.
-
please nextjs team this could be paired up with socket-io dynamic namespaces like room-[id] for an awesome lib interop |
Beta Was this translation helpful? Give feedback.
-
In a project I have the folowing page structure:
/
/[lang]
/[lang]/index.js
/[...all].js
This works fine until I had to also accept urls like: "/cms-page.html"(where "cms-page" is a variable). Obviously I have a match on /[lang]/index.js and I can, based on the query to check if it's and cms page or the normal page with a language selected.
I would love to have partial matching for routes so I can do stuff like:
/[lang]/[cmsPageName].html.js - matches any url that is 2 level deep and ends with ".html"
/faq-[faq-name].js - matches any url that starts with "faq-"
/faq-[faq-name]-page.js
/faq-[faq-name][faq-id].js
I think this will make the routing system a lot more powerful and would make a lot of developers's lives a lot easier.
At the moment the only way to do this is to create a lot of [...all] pages and based on the url return the page needed. The downside is that that page will contain all the possible pages and the bundle for those routes will be quite big(ex: for 5+ possible return values)
Beta Was this translation helpful? Give feedback.
All reactions