Get initial props using a HOC in _app.js same as when using directly in all _pages_
Using custom _app.js works only client-side
_app.js like here_app.js with withData :: see below
When the withData _HOC_ wraps each _Page_, the _GraphQL_ data fetched is available _server-side_ like:

instead wrapping the _custom_ _app.js is only available _client-side_, like:

| Tech | Version |
|---------|---------|
| next | 6.0.0|
| node | v8.11.0 |
| OS | OSX 10.11.6 |
| browser | |
| etc | |
import App, { Container } from 'next/app'
import React from 'react'
import withData from '../lib/withData'
class MyApp extends App {
static async getInitialProps({ Component, router, ctx }) {
let pageProps = {}
if (Component.getInitialProps) {
pageProps = await Component.getInitialProps(ctx)
}
return { pageProps }
}
render() {
const { Component, pageProps } = this.props
return (
<Container>
<Component {...pageProps} />
</Container>
)
}
}
export default withData(MyApp)
import App from '../components/App'
import Header from '../components/Header'
import Submit from '../components/Submit'
import PostList from '../components/PostList'
export default () => (
<App>
<Header />
<Submit />
<PostList />
</App>
)
cool, thank you @timneutkens !
Thank you very much <3 <3
Most helpful comment
See https://github.com/zeit/next.js/pull/4286