I have a website with a search on it. I'd like the user to be able to click on a search result and open the product in an overlay instead of reloading the whole page, however I would like the url in the url bar to be the correct product page so that is a user copies and pastes it or opens it in a new tab they'll get the product page. I'd also like the back button to work in both cases.
Here's a a more detailed explanation of the process.
- User navigates to the list page at /list?keywords=widget
- User clicks a product
- The contents of the product animate in on an overlay but the list page doesn't unload, it's still below the product page
- The URL bar updates to reflect that the user is on /products/123 but the products page isn't actually loaded.
- If the user hits the back button then the overlay disappears.
- If the user hits the refresh button while the overlay is open they will get an ssr version of the product page, the list page underneath is no longer there.
I thought at first that I might be able to use the {shallow:true} option on Next/Router to get this to work but the docs specifically say this only works for same page navigation (with a different query string).
My only idea is that I may be able to set the link up as a proper but hijack it in the browser to do something in pure javascript in the history state but I'm not sure whether the Next Router can be removed from the equation.
Just to be clear, I'm not asking for help with the product page or overlay itself, I can easily create shared components that show the same content in both situations, it's specifically the routing and URL issues I'm requesting help with.
Any help, even just a pointer in the right direction would be really appreciated.