N
Nuxt7mo ago
marvin

Best practice for using the Route for storing state

Given a page /items which has a grid of the available items fetched from the api, I want a modal for adding/creating a new item. I would like to make the modal appearance (including transitions, if possible) dependent on the route. The modal should show when the url is /items/create, and don't show when the url is just /items. I looked for a solution, but - maybe because of wrong search terms - found no nice and clean solution. Are there any best practices for this?
2 Replies
Mads
Mads7mo ago
I believe what you are talking about is modal routes. It’s a bit complex to build as there can be many edge cases. Luckily there is a module for that. https://nuxt-pages-plus.pages.dev/routing/modal-routes/ It is great practice to add /create for creation, this way you can link to the page of creation. Adding a modal is just a style preference. Best of luck.
Modal Routes
Modal Routes can navigate modal routes with real-time URL changes for seamless browsing.
marvin
marvinOP7mo ago
I had quick a look into that. Seems exactly to be what I need, seems a bit strange to use but I think that will settle once I am using it and not just looking into the docs. Thank you very much!
Want results from more Discord servers?
Add your server