Skip to content

Instantly share code, notes, and snippets.

@zsherman
Created August 16, 2017 15:56
Show Gist options
  • Save zsherman/a8711187724db5ac96b4c4e391f245a5 to your computer and use it in GitHub Desktop.
Save zsherman/a8711187724db5ac96b4c4e391f245a5 to your computer and use it in GitHub Desktop.
import Document, { Head, Main, NextScript } from 'next/document'
import { ServerStyleSheet } from 'styled-components'
import 'styles/global-styles';
export default class SiteDocument extends Document {
render () {
const sheet = new ServerStyleSheet()
const main = sheet.collectStyles(<Main />)
const styleTags = sheet.getStyleElement()
return (
<html>
<Head>
<meta charSet="utf-8" />
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
{styleTags}
</Head>
<body>
<div className="root">
{main}
</div>
<NextScript />
</body>
</html>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment