import Document, { Head, Main, NextScript } from 'next/document' import styleSheet from 'styled-components/lib/models/StyleSheet' export default class MyDocument extends Document { static async getInitialProps ({ renderPage }) { const page = renderPage() const styles = styleSheet.rules().map(rule => rule.cssText).join('\n') return { ...page, styles } } render () { return ( My page
) } }