Skip to content

RFC: getInitialProps/getClientSideProps #364

Closed
@hazae41

Description

@hazae41

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions