Unverified Commit d3955cdf authored by Kaic Bastidas's avatar Kaic Bastidas Committed by GitHub

TypeScript documentation for _document.tsx (#15386)

- Update the [Custom Document page](https://nextjs.org/docs/advanced-features/custom-document) to include an example using `DocumentContext`.
parent ebe4bb1e
......@@ -85,3 +85,21 @@ class MyDocument extends Document {
export default MyDocument
```
## TypeScript
You can use the built-in `DocumentContext` type and change the file name to `./pages/_document.tsx` like so:
```tsx
import Document, { DocumentContext } from 'next/document'
class MyDocument extends Document {
static async getInitialProps(ctx: DocumentContext) {
const initialProps = await Document.getInitialProps(ctx)
return initialProps
}
}
export default MyDocument
```
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment