Next does not render SSR page when going back in history pushed via intercepted route #76172
Unanswered
goodpixels
asked this question in
App Router
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all, I have searched for a similar problem, but couldn't find anything.
I have two routes:
/feedand/photos/[id]. After some initial struggles I ended up setting up an intercepting route from/feedto/photos/[id]in a@modallayout slot. So far this works as expected:/feedpage and navigates to any of the/photo/[id]routes, the interceptor kicks in and renders the photo in a modal.<Link>component, which allow the user to see other photos. This also works as expected./feedroute within the intercepted/photo/[id]modal, they are able to use back and forward history buttons in the browser correctly. That is, the modal content changes accordingly, and the URL of the page is updated as well, despite the fact that technically the user is still on the/feedroute. So given the following journey:/feed->/photo/1->/photo/2->/photo/3when the user goes all the way back to/feedin history, the modal gets closed at the end and they're back to the initial state of the/feedpage. This is exactly what I want and it works great./photo/3), they will be served an SSR version of the actual/photos/[id]route instead of the feed modal, which is also great. This is also exactly what I want - to be able to link directly to an SSR photo page without the distratcion of the feed in the background./photo/3they go back in history again, I would expect Next to render the previous entry also as an SSR page (so from/photos/3->/photos/2both pages should be SSR). But this doesn't happen. Instead only the URL of the page changes, and despite navigating to/photo/2, the user still sees the contents of the page from/photo/3.At first I thought I might need to listen to path changes using
useEffect, but then it occurred to me - hang on, but this is apage.tsxand it's meant to be a server page, not a modal.I'm probably doing something wrong, or I'm not doing something I should, but maybe it's a limitation of the framework.
Can anyone chip in and advise?
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions