How to use optional param in dynamic routes #14358
-
In our project, we have used optional parameters in some cases like for profile page
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
You should've kept searching then, it's not that hard to find. :) There also is the concept of optional catchall routes which currently is experimental: |
Beta Was this translation helpful? Give feedback.
You should've kept searching then, it's not that hard to find. :)
Its right here: https://nextjs.org/docs/routing/dynamic-routes#catch-all-routes
You put it like this:
[...params]
and get an array of values.There also is the concept of optional catchall routes which currently is experimental:
https://nextjs.org/docs/routing/dynamic-routes#optional-catch-all-routes
But it looks like you may not need that, as the
username
param seems to be always present.