Skip to content

Instantly share code, notes, and snippets.

@nirzaq
Created March 8, 2018 03:46
Show Gist options
  • Save nirzaq/ab434aa9897791f99819e51b68e916d6 to your computer and use it in GitHub Desktop.
Save nirzaq/ab434aa9897791f99819e51b68e916d6 to your computer and use it in GitHub Desktop.
Override Next.js _document.js to support PWA
import Document, { Head, Main, NextScript } from "next/document";
import flush from "styled-jsx/server";
export default class extends Document {
static getInitialProps({ renderPage }) {
const { html, head, errorHtml, chunks } = renderPage();
const styles = flush();
return { html, head, errorHtml, chunks, styles };
}
render() {
return (
<html lang="id">
<Head>
<meta charSet="utf-8" />
<meta httpEquiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<link rel="icon" href="/static/favicon.ico" />
<link rel="manifest" href="/static/manifest.json" />
<meta
name="description"
content="Simple PWA Using Next.js"
/>
<title>WWWID - NEXT PWA </title>
</Head>
<body>
<Main />
<NextScript />
</body>
</html>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment