Skip to content

Cleaner server-side dependency injection into getInitialProps? #1117

@fionawhim

Description

@fionawhim

Just wanted to raise something that I’ve noticed using the beta.

During server-side rendering (using the custom routing and renderToHTML), there are some server-side dependencies I want to make available (for example, a means of injecting requests directly into my Hapi app so that the server-side data fetching doesn’t go through a network interface). In some cases I also have data to seed an initial Redux store based on the request.

Currently I’m getting this data in by attaching custom properties to the Node Request object that’s passed in to the context.

This is fine, though a little awkward. I was raising this up in case you want to make it easier to add server-specific properties to the getInitialProps context.

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