question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow bypass "getData" of page component on client side navigation

See original GitHub issue

Feature request

Is your feature request related to a problem? Please describe.

@aralroca shared some useful insights on how he archived his app performance.

Using SPA navigation (clicking a Link or Router.push) the page is rendered after getInitialProps or getServerSideProps is resolved.

However, with getInitialProps you can “skip” fetching the data to don’t block the navigation. So you can render the new page with skeletons just at the same moment that you clicked the Link.

With this, I’m using getInitialProps only for real SSR and not for client navigation. Doing the fetch navigation on a useEffect.

But getServerSideProps is not possible (or at least I dunno how to handle this) to do the same behavior.

He still relies on getInitialProps instead getServerSideProps because it allows him to skip client-side data fetching on route change. He loads the data on the next useEffect(..., []) lifecycle. SSR is not affected. In that scenario, he can ship the app skeleton faster to the user and load the data afterward on the client.

This sounds reasonable when your static content dominate the page which is often the case.

Describe the solution you’d like

export const config = {
   clientDataFetch: false
}

export async function getServerSideProps(){
  return {
    props: await fetchProps()
  }
}

Working PR which demonstrates the behavior by defining skipDataFetch on Link component. https://github.com/StarpTech/next.js/tree/add/skip_data_fetch

Additional context

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:25
  • Comments:26 (15 by maintainers)

github_iconTop GitHub Comments

19reactions
JClackettcommented, Jul 23, 2020

has there been any progress on this? Im using getServerSideProps for seo reasons to provide the initial data for some pages, then caching it (using apollo). However when navigating back to the same page (data is already cached) its re-running the getServerSideProps and blocking the navigation until that resolves.

The data fetching in the getServerSideProps isn’t super slow, but the process of calling the getServerSideProps is very slow and this leads to a very slow navigation to pages that contain getServerSideProps.

Am I missing something here?

Thanks

16reactions
vaniyokkcommented, Mar 25, 2021

Any activity on this? It’s really annoying problem! Very common plugins (next-i18next, next-translate) are already dropped support for getInitialProps. All new examples are using getServerSideProps as preffered solution and there is NO WAY to eliminate extra network call every time route changed? Nobody uses client-side cache? Hmm… don’t believe it. Waiting for experimental react feature is not a solution for now.

You really need to think about it. I don’t understand why this issue takes so little attention from community…

Read more comments on GitHub >

github_iconTop Results From Across the Web

getInitialProps - Data Fetching - Next.js
getInitialProps enables server-side rendering in a page and allows you to do initial data population, it means sending the page with the data...
Read more >
Best practice for Next.js data fetching inside a component
Data Fetching for Global Components. So how do we get around this? The best answer I have is apollo-client and to do the...
Read more >
Call a web API from ASP.NET Core Blazor - Microsoft Learn
Blazor WebAssembly examples based on an client-side WebAssembly app that calls a web API to create, read, update, and delete todo list items ......
Read more >
Client-Side Caching of Apex Method Results
Marking a method as cacheable improves your component's performance by quickly showing cached data from client-side storage without waiting for a server ...
Read more >
Server-Side Rendering with Nuxt.js Application - Medium
Server -Side Rendering means that the whole content of the website (which ... will override data you have already defined in your component...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found