--- description: Extend the default document markup added by Next.js. --- # Custom `Document` A custom `Document` is commonly used to augment your application's `` and `
` tags. This is necessary because Next.js pages skip the definition of the surrounding document's markup. A custom `Document` can also include `getInitialProps` for expressing asynchronous server-rendering data requirements. To override the default `Document`, create the file `./pages/_document.js` and extend the `Document` class as shown below: ```jsx import Document, { Html, Head, Main, NextScript } from 'next/document' class MyDocument extends Document { static async getInitialProps(ctx) { const initialProps = await Document.getInitialProps(ctx) return { ...initialProps } } render() { return (