Skip to content

Route to new page without invoking getInitialProps #8774

@brettinternet

Description

@brettinternet

Feature request

When using a next export static build, I would like the getInitialProps method to fire only during the build step and not on the client for select page components. (Related StackOverflow question)

On a static client, Next.js invokes this method before the page component is rendered in order to provide the necessary props for the component. Thus, large requests can delay the client's first paint as this is a blocking request.

I would like to selectively ignore getInitialProps for a page component, and instead use the props provided by getInitialProps during next export.

I'm unwilling to move my slow API request to componentDidMount in order to avoid the blocking request because I want to use the data returned during the build step to populate the static HTML, and this particular request doesn't need to be dynamic or updated after the build.

Shallow routing works only for same page URL changes.

- Shallow Routing

For this feature request, is it possible to implement something similar to shallow routing, but for new pages?

To circumvent getInitialProps on static exports, I currently have to use a standard JSX anchor <a href="/next-page"> to avoid invoking the method. This does cause a full page refresh which is a poor solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions