Repository navigation
Bug reportDescribe the bugClicking on Link element (from "next/link" lib) with property "shallow" being set to true will still trigger the target page's getServerSideProps method (on the server) every single time. To Reproduce:(1) create 2 pages: page1 and page2 under "pages" folder. (4) Run "npm run build" and "npm run start", directly launch the page2 on browser. Expected behaviorThe expected behavior is that, if shallow prop is set to true, the target page should only do the client-transition on the browser without going back to the server. This expectation is based on the NEXT.JS doc site as follows: Here is the quote from the NEXT.JS doc page "https://nextjs.org/docs/api-reference/next/link": To be consistent, Router from "next/router" should behave the same way when calling its push method with option of { shallow: true }. Unfortunately I am not able to find any mentioning of "getServerSideProps" in the documentation for "next/router" lib. A note about convention for SSR (Server-Side-Rendering) capability:By convention, if a page is SSR-enabled, SSR operations only gets triggered by a direct hit via browser's address bar URL input or refresh. The page should still retain client side transition capability whenever it is needed for better user-perceived performance. In such case, the data is usually retrieved via Ajax. This is the behavior that I am looking for. System information
Thanks |
Replies: 7 comments 9 replies
|
As per https://nextjs.org/docs/routing/shallow-routing#caveats
|
|
@Janpot , thanks for the reply and clarification. If "shallow" option cannot be used to enable "Client Transition" for SSR-enabled pages, then, would it be correct to say that, under NEXT.JS framework, if a page is marked as SSR capable (via getServerSideProps), this page will never be able to do "Client Transition"? In other words, this page will be permanently locked in with the "Server Side Rendering" execution path? Every page-hit will mean a complete page reload from the web server? Please kindly confirm... By any chance do you have a solution to allow a SSR-enabled page to do Client Transition? Thanks again. |
Not at all, next.js will only download the javascript bundle that is needed and the data generated by |
|
@Janpot , thanks again for the reply - I also done some learning and reading on my own regarding "getServerSideProps". What I learned seems to match up with what you just said: There won't be a full page reloading - it will be just JSON data being fetched to the client side. I think I will close this ticket since my questions are all resolved. Thanks again. |
|
@Janpot Can I please get an idea of the thinking behind the design decision to not support the described behaviour? I'm having the same problem here. Scenario: we have completely separate frontend and backend applications, our backend is not written in node. We are using getServerSideProps to support SSR, and it works great, but breaks the normal React behavior in terms of forcing a roundtrip to the node server to get the server props which are delivered by our backend. This is causing a substantial delay due to the proxying of our backend by node, which looks like it's been forced to work this way, with no way to opt out. While everything is working, the resulting experience is severely degraded and we very much wish to use getServerSideProps, but allow actual shallow rendering (normal React behaviour) on client-side route changes. Can you please add support for this feature? It's causing a lot of grief for our team due to the massive latency it has introduced. |
|
Two years later, is there still no way to skip the getServerSideProps request on client side navigation with next/link? It's honestly pretty baffling that this is not supported as forcing getServerSideProps when you already have all the data on the client really degrades performance and seems to me like a very typical scenario. In my case I want to support SSR for the intial page load but then I already have all the data I need on the client ready to be used by any other page, so performing an extra request every time the user moves to another page is completely unnecessary. |
As per https://nextjs.org/docs/routing/shallow-routing#caveats