Catch-all route with optional segments?
Hey, I'm trying to acheive the following routing structure in a project:
- /files
- /files/another/nested/route
But I want to be able to verify if I'm on the root route which is /files, is it possible to make the segments optionals like in NextJS: https://nextjs.org/docs/pages/building-your-application/routing/dynamic-routes#optional-catch-all-segments so if I'm at /files i get an empty array and make the necessary verifications from there? I attached my current file structure
The reason i'm using this files structure is because I have a link in the layout that I want to be styled as active as long as i'm at /files/...whatever (whether is at the root or not), and that's the only way the router will apply the router-link-active class, because if I delete the files and only leave the router will no longer apply the active class as it should
Routing: Dynamic Routes | Next.js
Dynamic Routes are pages that allow you to add custom params to your URLs. Start creating Dynamic Routes and learn more here.
0 Replies