How getInitialProps get called differently on server and client

getInitialProps in next.js is normally used to fetching data for the component. It can be called on both server and client side. I wrote a demo and below is what i found:

  1. A page request to the server will only trigger getInitialProps get called on the server and NOT on client side.
  2. Client side page navigation to other pages wrapped by <Link> will trigger getInitialProps only on client side and NOT on server side.

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *