Closed
Description
IMHO getInitialProps is very useful but complex to re-implement properly and to bundle properly
What I suggest is getServerSideProps
, which we already have, combined with a new function named getClientSideProps
.
This function would generate the props client-side, just like getInitialProps, but without being compatible with the server
- First page load:
getServerSideProps
is called - When the user navigates:
getClientSideProps
is called
This way, no request to the server is made each time the user clicks somewhere, especially if the client already has the props in a cache (e.g. swr)
If getClientSideProps
is NOT defined, then a request is made and getServerSideProps
is called server-side (current behaviour)
The bundling of those two functions is easier than getInitialProps
, and their behavior is more understandable and less error-prone