Dynamic route with sub-paths (eg. /[locale]/dashboard) #11859
-
Hi there, I’m trying to build a multi-region website with next.js, however dynamic routing is not working the way I was expecting. Here is an example setup:
In this scenario I would expect the following URLs to work and to be eligible for rendering at build time:
I would expect the following to 404:
With appropriate Currently my Have I made a mistake in my implementation somewhere? If so I will try to provide a minimal example to reproduce. If it’s not the way dynamic routing currently works, is it feasible to support this case or is there something fundamental about the way it is implemented that would make it too difficult to change now? Is there some other way I can achieve my goal, preferably without having to implement a custom server or losing the advantages of hybrid server-rendered/statically-generated next.js. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
You have to add getStaticProps/getStaticPaths to all routes that have dynamic parameters, otherwise they become auto-exported and won't have the The way that you're outlining that you'd expect it to work would mean that we'd have to block routes from rendering, significantly slowing down build times. |
Beta Was this translation helpful? Give feedback.
You have to add getStaticProps/getStaticPaths to all routes that have dynamic parameters, otherwise they become auto-exported and won't have the
locale
parameter until after hydration.The way that you're outlining that you'd expect it to work would mean that we'd have to block routes from rendering, significantly slowing down build times.
On top of that it would not work as expected with
fallback: true
behavior and incremental static generation.