Next.js Discord

Discord Forum

Caching issue with Intercepting Routes used for Modals

Unanswered
New Guinea Freshwater Crocodile posted this in #help-forum
Open in Discord
New Guinea Freshwater CrocodileOP
I've been following this example for using intercepting routes to create modals in an SSR context:
https://nextjs.org/docs/app/building-your-application/routing/intercepting-routes#modals

My issue is replicable on the example app provided in the guide:
https://nextgram.vercel.app/

Steps to reproduce:
1. Visit https://nextgram.vercel.app/
2. Click on the frame marked 1. Note how a modal opens up.
4. Refresh the page. Note how you're now rendering the page-version of the modal content.
5. Hit the browser's back button.
6. Click on the frame marked 1. Note how the modal no longer opens up - instead you're once again brought to the page-version of the modal content. I think this is an unintentional bug, and if it's not, I'd appreciate any pointers to make this not happen.

I believe this is due to caching. From what I can tell, once the page-version of the modal has loaded once, the intercepting route no longer takes precedence in a soft navigation. Once that happens, there's no way to open up the modal.

0 Replies