Next.js Discord

Discord Forum

Can you have a partially dynamic route?

Unanswered
Nile Crocodile posted this in #help-forum
Open in Discord
Nile CrocodileOP
I am working on a college sports website and trying to make sure the routing scales as best as possible without me having to hardcode a new route anytime we add a sport we want to cover. I was originally doing /news for all news, then /news/[division] for division (DI, DII, DIII) specific news, and then /news/[division]/[conference] for conference specific news. That worked great when we only wanted to cover college football. However, we now want to cover other sports. I had started with hardcoding /college-football/* but I really don't want to hardcode a new route every single time we add a new sport. I tried doing /college-[sport]/* but that doesn't work. All of our articles are rendered on /[slug] and I want to keep them there. Is there a way this can be accomplished?

I also don't want to get into the mess of rewrites in my next config if I can avoid it.

0 Replies