Is it possible on NextJS to have a dynamic route that will match /country
and /country/city
, but will not match /country/city/whatever_content_here
? I want to show the same page for both of the above routes, even if I send only the country
or both the country
and the city
.
I know you can do this by using [...country_city]
but this would also match for example /country/city/street
which is not the desired functionality.
Yes this is possible.
Look at the api reference here:https://nextjs.org/docs/routing/dynamic-routes#catch-all-routes
Based on that you can write logic to check the country_city array and based on that display content
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.