Files
Jan PotomsGitHubJJ Kasperkodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
9300151118 Allow pages to be async modules to enable top-level-await (#17590)
Co-authored-by: JJ Kasper <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-10-14 11:55:42 +02:00

26 lines
548 B
React

import Document, { Html, Head, Main, NextScript } from 'next/document'
const docValue = await Promise.resolve('doc value')
class MyDocument extends Document {
static async getInitialProps(ctx) {
const initialProps = await Document.getInitialProps(ctx)
return { ...initialProps, docValue }
}
render() {
return (
<Html>
<Head />
<body>
<div id="doc-value">{this.props.docValue}</div>
<Main />
<NextScript />
</body>
</Html>
)
}
}
export default MyDocument